This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes How to set actionForm initial values from session attributes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to set actionForm initial values from session attributes" Watch "How to set actionForm initial values from session attributes" New topic
Author

How to set actionForm initial values from session attributes

Sam Sunamin
Ranch Hand

Joined: Mar 16, 2007
Posts: 113
Requirements:

I need to populate the initial values from Session attributes using actionForm. Can anyone help me?

For Example, I have a customer whose credit card's number, address, phone number and so on are already stored as session attributes.

Before the customer pay his bill, he may change his credit information. So I used action form to work with action class and the action form should have the initial values from attribute.

Help me, please and thank you in advance.
[ July 18, 2007: Message edited by: Sam Sunamin ]

Yours Sam<br />SCJP5.0 97%<br />SCBCD5.0 72%
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
This sounds pretty straightforward to me. Just create an Action class that forwards to the JSP. In that Action class, retrieve the values from the session and put them in the ActionForm. Example:

In the above code, the variable form represents the ActionForm object passed into the execute method as a parameter.
[ July 18, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Sam Sunamin
Ranch Hand

Joined: Mar 16, 2007
Posts: 113
Thank you so much,Merrill.

I got the idea.
 
jQuery in Action, 2nd edition
 
subject: How to set actionForm initial values from session attributes
 
Similar Threads
Problem with iframe in struts 1.1 applicaton
Servlet code for updating data in database
ActionForm with session scope
why bother with struts HTML tags?
Getting Param values from JSP tp servlet