struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chappell, Simon P" <>
Subject RE: Newbie question about action forms
Date Mon, 23 Sep 2002 18:44:44 GMT
Good question. I'll tell you what we did on my most recent project and you can decide if it
counts as a good answer.

I take a 100% view (no pun intended) that the reason for existence of an ActionForm is to
be the communication channel between actions and pages. On a submit, struts scrapes the form
and loads the form with the values and hands it off to the action. When an action returns,
the form data is taken and inserted into the page fields. Period. (Well, except for some validation,
but that's icing on the cake and not a huge factor in my thinking about forms).

If you have data that is to be transfered from action to action and that has no meaningful
part in the view, then I would suggest that a form is not the way that I would go at first
blush. I would carefully consider, for small amounts of data (very small!), that you may wish
to store some info in the session itself. We just did that on my most recent project. We had
three small objects and we stored them in the session, a user object, a station object and
a shipment object. This allowed our design to be much cleaner by not passing around these
objects from page to page and action to action. Other approaches include persistence into
a database or using a singleton data object inside a servlet.

Hope this helps.


Simon P. Chappell           
Java Programming Specialist            
Lands' End, Inc.                                   (608) 935-4526

>-----Original Message-----
>From: Taylor, Jason []
>Sent: Monday, September 23, 2002 12:40 PM
>To: 'Struts Users Mailing List'
>Subject: RE: Newbie question about action forms
>Simon-- do you think you should use ActionForms to transfer 
>objects that are
>shared between actions and never changed on the front end?  I can see
>arguments either way, what's your opinion?
>-----Original Message-----
>From: Chappell, Simon P []
>Sent: Monday, September 23, 2002 9:54 AM
>To: Struts Users Mailing List; Miguel Angel Medina Lopez
>Subject: RE: Newbie question about action forms
>The "Struts way" is to transfer data between pages and actions using an
>ActionForm object. This holds true for either direction. It is standard
>practice to transfer this data in an Action Form. Please refrain from
>putting data into the session as a transfer mechanism. Struts will
>automagically make the form data available in the page that 
>you call using
>the reverse of the magic that it used to extract form data 
>from your calling
>Simon P. Chappell           
>Java Programming Specialist            
>Lands' End, Inc.                                   (608) 935-4526
>>-----Original Message-----
>>From: Miguel Angel Medina Lopez []
>>Sent: Monday, September 23, 2002 11:48 AM
>>To: Struts Users Mailing List
>>Subject: Newbie question about action forms
>>Hi all:
>>In the Struts framewok information from the form to the 
>action class is
>>transfer through an ActionForm, but when I want to transfer 
>>information from
>>the Action to a new HTML (JSP) page, for example a list of 
>>products, What is
>>better? Use an action form or directly storing the list in the session
>>object with a particular key.
>>To unsubscribe, e-mail:   
>>additional commands, 
>>e-mail: <>
>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message