Manning's Countdown to 2014
. Use discount code crdotd14 all month for 50% off every deal.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
How to set actionForm initial values from session attributes
Joined: Mar 16, 2007
Jul 18, 2007 08:14:00
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%
Joined: Feb 15, 2005
Jul 18, 2007 10:04:00
This sounds pretty straightforward to me. Just create an Action class that forwards to the
. In that Action class, retrieve the values from the session and put them in the ActionForm. Example:
MySessionUserObject user = (MySessionUserObject)request.getSession().getAttribute("mySessionUserObjet"); MyActionForm myForm = (MyActionForm) form; myForm.setCreditCard(user.getCreditCard()); myForm.setShoeSize(user.getShoeSize()); // etc. return mapping.findForward("success");
In the above code, the variable
represents the ActionForm object passed into the execute method as a parameter.
[ July 18, 2007: Message edited by: Merrill Higginson ]
Joined: Mar 16, 2007
Jul 18, 2007 10:49:00
Thank you so much,Merrill.
I got the idea.
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
subject: How to set actionForm initial values from session attributes
why bother with struts HTML tags?
ActionForm with session scope
Servlet code for updating data in database
Problem with iframe in struts 1.1 applicaton
Getting Param values from JSP tp servlet
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013