I am not doing things this way. I presented this as a hypothetical case and my question is why is this bad? I mean what problems can we run into using this technique.
Thanks for the write up but I would appreciate something that in more in detail. Thanks, Harsh. -----Original Message----- From: Michael Jouravlev [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 28, 2007 3:32 PM To: Struts Users Mailing List Subject: Re: Struts session scoped forms On 2/28/07, Chaudhary, Harsh <[EMAIL PROTECTED]> wrote: > I have page1.jsp which has a form which calls Page1Action which forwards > to page2.jsp. Also, session scoped Page1Form and Page2Form. > > In Page1Action, I do: > > Page2Form frm = new Page2Form(); > frm.setSomeVariable("Some Value"); > > Then read this value in page2.jsp to display. > > I feel the bad part is initializing the Page2Form myself. This works > correctly because I think Struts checks for the form being available in > all scopes, finds it in session, and just uses that instead of creating > a new one in the Page2Form constructor. > > Is this way of doing things correct? If not why? Or am I zoned out too > much to make sense? This is okay. Not great to my taste, but okay. You should use the same key as "name" attribute in the action mapping. I would recommend you another pattern, but I will not going to share my way of doing this until a new version of Struts1 that would allow to turn off automatic reset/populate of a form is released. Why would you create an ActionForm for pure output purposes? You can create a POJO or even access properties of your business object. On a side note, in Struts actions precede pages. An action receives a request and then displays a page. In your case, it obtains information from page1, but it renders page2. Even this is not true. An action does not obtain information from a page, it just receives a request and it does not care where the request comes from. So talking in terms "page1.jsp calls Page1Action" is not entirely correct to me. Therefore I would name your action as Page2Action, not Page1Action, that would be clearer for me. Michael. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]