-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Michael and Chaudhary,

Michael Jouravlev wrote:
> 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.

Why not add another <action> mapping in between Page1Action and page2?
Something like this:

page1.jsp -- submit --> Page1Action -- fwd --> PrepPage2 --> page2.jsp

Then, set the "name" for Page1Action to "Page1Form" and the "name" for
PrepPage2 to "Page2Form". Then, you can use the form that gets provided
by Struts directly in your execute method.

>> 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.

If you call the constructor for Page2Form, you /will/ get a new object.
Struts has nothing to do with this. You must be doing something else in
your action to put this object into session or request scope.

> Why would you create an ActionForm for pure output purposes? You can
> create a POJO or even access properties of your business object.

If page2.jsp contains a form, then it is perfectly natural to use an
ActionForm to shuttle data from the action to the page.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF5vHA9CaO5/Lv0PARAk0GAKCoH/CG22PzE7M60O0IDm26PUd1qACgtKYn
FhkoBJ8OQ2oUIwvoikdlciM=
=JWjA
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to