File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes How I can access session objects within Form object extended ActionForm class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How I can access session objects within Form object extended ActionForm class" Watch "How I can access session objects within Form object extended ActionForm class" New topic
Author

How I can access session objects within Form object extended ActionForm class

Tob
Greenhorn

Joined: Jul 02, 2003
Posts: 3
How I can access data or objects stored into session object (stored from an earlier screen)within Form object extended ActionForm class.
For example when the user login I am storing user id and preferences in session. Later on I need the same parameters from session to do processing that is based on user ID.
I know how to do that in object that extends Action class but not sure how to do it in Form. Any help is highly appreciated!
Perry McKenzie
Greenhorn

Joined: Jul 16, 2003
Posts: 23
Hi Toplica,
If I understand you question correctly, here's what I would do...
I would make the userID and preferences (your examples) attributes in your ActionForm super class. That way, every ActionForm class is extended has those values. I haven't entirely thought this through or tested it, but it seems in theory like it should work. You may have to reset these values every time you change ActionForms, but as long as they are children of the same super class...
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
insert hidden tags into your form and fill it while runtime with the two values you like. Then add this fields also to your form, and you always will have the correct values in your form class.
The prob is that you cannot access the Request or Session in the FormClass.
I think thats only possible in the validate method.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How I can access session objects within Form object extended ActionForm class