The action class does not have state information. Each request is handled by a different object. If there are appropriate form input fields in the jsp, struts params interceptor will call the getters and setters on form submit, calling constructors and instantiating new objects for action fields if they have not already been created. This can create illusion of persistence of objects themselves.
As for storing information in two forms; two forms can store different information, and set it into the action when they are submitted. But you should remember that you can only submit one of the forms at a time. Normally this means that you can't use the information in the other any more as a new page is loaded. On Wed, May 14, 2008 at 1:16 PM, Milan Milanovic <[EMAIL PROTECTED]> wrote: > Actually my question is next, if my form store information to attribs of my > action class, > would another form for the same class store information to attribs of the > same class (but another > attribs) ? > > -- > Thx, Milan > > > ----- Original Message ---- > From: Milan Milanovic <[EMAIL PROTECTED]> > To: Struts Users Mailing List <user@struts.apache.org> > Sent: Wednesday, May 14, 2008 12:05:06 PM > Subject: Re: [struts 2] Two forms for one action > > Hi, > > but how my action class is storing objects which are shown in jsp and also > it store objects inserted through jsp ? This mean that it have state > information ? > > -- > Thx, Milan > > > > ----- Original Message ---- > From: Jukka Välimaa <[EMAIL PROTECTED]> > To: Struts Users Mailing List <user@struts.apache.org> > Sent: Wednesday, May 14, 2008 7:53:13 AM > Subject: Re: [struts 2] Two forms for one action > > Both forms don't call the same *instance* of the action class. Neither does > one form, actually. > For each request, Struts 2 uses a different instance of the same class. > Once > the result is > rendered, the action object is no longer used. If you want to retain action > state information, you > must store it somehow-through hidden fields in form or in session, for > example. > > On Tue, May 13, 2008 at 6:13 PM, Milan Milanovic < > [EMAIL PROTECTED]> > wrote: > > > Thank you Randy. > > >They could, if it were me I would have different methods on the action > > class > > >to handle the different forms if I were to do it this way. Personally I > > >would create an action class for each form. > > > > No, I cannot do this, because both forms need to work with the same > > objects in > > a action class. First form works with some header data, and the second > > with list > > of data and show table also of such data. > > I asked this, because I wasn't sure if both forms would call the same > > instance of > > action class. > > -- > > Thx, Milan Milanovic > > ----- Original Message ---- > > From: Randy Burgess <[EMAIL PROTECTED]> > > To: Struts Users Mailing List <user@struts.apache.org> > > Sent: Tuesday, May 13, 2008 5:09:19 PM > > Subject: Re: [struts 2] Two forms for one action > > > > They could, if it were me I would have different methods on the action > > class > > to handle the different forms if I were to do it this way. Personally I > > would create an action class for each form. > > > > Regards, > > Randy Burgess > > Sr. Web Applications Developer > > Nuvox Communications > > > > > > > > > From: Milan Milanovic <[EMAIL PROTECTED]> > > > Reply-To: Struts Users Mailing List <user@struts.apache.org> > > > Date: Tue, 13 May 2008 07:58:29 -0700 (PDT) > > > To: Struts Users Mailing List <user@struts.apache.org> > > > Subject: Re: [struts 2] Two forms for one action > > > > > > I have one more question about this, if I define two <s:forms> in one > > page > > > would > > > they work with the same action class ? > > > > > > -- > > > Thx, Milan Milanovic > > > ----- Original Message ---- > > > From: Jim Kiley <[EMAIL PROTECTED]> > > > To: Struts Users Mailing List <user@struts.apache.org> > > > Sent: Monday, May 12, 2008 6:15:07 PM > > > Subject: Re: [struts 2] Two forms for one action > > > > > > Milan, > > > > > > I'm not a Struts 1 guy, so this advice might not be useful to you > > (because > > > you didn't say whether this was a Struts 1 or 2 situation). But in my > > Struts > > > 2 app I have plenty of places where I have multiple <s:submit> buttons > > each > > > triggering different action methods on the same action class. > > > > > > jk > > > > > > > > > On Mon, May 12, 2008 at 12:10 PM, Milan Milanovic < > > [EMAIL PROTECTED]> > > > wrote: > > > > > >> Or maybe I should define two submit buttons for the same form and > > action > > >> class ? > > >> -- > > >> Regards, Milan > > >> > > >> > > >> ----- Original Message ---- > > >> From: Milan Milanovic <[EMAIL PROTECTED]> > > >> To: Struts Users Mailing List <user@struts.apache.org> > > >> Sent: Monday, May 12, 2008 5:57:50 PM > > >> Subject: [struts 2] Two forms for one action > > >> > > >> Hi, > > >> I need to have classic master/detail jsp page, so I need actually two > > >> forms in a jsp page to works with one action class, > > >> one main form that works with main elements of my object (e.g. User > > name, > > >> surname,...) for header and another one which works > > >> with some list that belongs to my main object (e.g., User.privileges) > > >> below such header part. How can I define this ? > > >> -- > > >> Thx, Milan Milanovic > > >> > > >> > > >> > > >> > > > _____________________________________________________________________________ > > >> _______ > > >> Be a better friend, newshound, and > > >> know-it-all with Yahoo! Mobile. Try it now. > > >> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ > > >> > > >> > > >> > > >> > > >> > > > _____________________________________________________________________________ > > >> _______ > > >> Be a better friend, newshound, and > > >> know-it-all with Yahoo! Mobile. Try it now. > > >> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ > > >> > > > > > > > > > > > > -- > > > Jim Kiley > > > Technical Consultant | Summa > > > [p] 412.258.3346 [m] 412.445.1729 > > > http://www.summa-tech.com > > > > > > > > > > > > > > > > > This email and any attachments ("Message") may contain legally privileged > > and/or confidential information. If you are not the addressee, or if > this > > Message has been addressed to you in error, you are not authorized to > read, > > copy, or distribute it, and we ask that you please delete it (including > all > > copies) and notify the sender by return email. Delivery of this Message > to > > any person other than the intended recipient(s) shall not be deemed a > waiver > > of confidentiality and/or a privilege. > > > > > > > > > > > > > >