you probably only want one form set to request scope.

If you use different forms, then that form is only valid for the one specific action it is associated with. For instance, if the submitting page contains a form that has a textbox where you can input your name. And you want to display the name on the next page using struts internal form processing, then the forms must be the same.

As far as scope, I think you almost always want to use request scope. Session scope does wacky things. Don't think of the data as only being request scope - because as long as your workflow has that form in each page with the associated parameters(if you're not displaying them but need them preserved between requests - use html:hidden) then the data is almost like being session scoped.

HTH,
Ben


From: "Michael Cardon" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Subject: Best Practices in Struts for Form objects?
Date: Thu, 6 Nov 2003 07:35:04 -0800

Hello,

If I have 5 Action classes that all need to reference the same Form object,
should I map each Action to the same form name, or use different names for
each of the Forms in the Actions?  Does it make a difference if I�m using
session scope vs. request scope?

Example using the same form names, same form class:

<form-bean name="pwForm" type="mim.struts.form.SelectForm"/>

    <action    path="/teacherPw"
               type="mim.struts.action.pw.StudentPwAction"
               name="pwForm"
              scope="request"
           validate="false"
          parameter="dispatch">
      <forward name="success"      path="mim.pw.list"/>
    </action>

    <action    path="/studentPw"
               type="mim.struts.action.pw.StudentPwAction"
               name="pwForm"
              scope="request"
           validate="false"
          parameter="dispatch">
      <forward name="success"      path="mim.pw.list"/>
    </action>

... 3 more actions ....


Example using diferent form names, same form class:


<form-bean name="teacherpwForm" type="mim.struts.form.SelectForm"/>
<form-bean name="studentpwForm" type="mim.struts.form.SelectForm"/>

    <action    path="/teacherPw"
               type="mim.struts.action.pw.StudentPwAction"
               name="teacherpwForm"
              scope="request"
           validate="false"
          parameter="dispatch">
      <forward name="success"      path="mim.pw.list"/>
    </action>

    <action    path="/studentPw"
               type="mim.struts.action.pw.StudentPwAction"
               name="studentpwForm"
              scope="request"
           validate="false"
          parameter="dispatch">
      <forward name="success"      path="mim.pw.list"/>
    </action>

... 3 more actions ....

Thanks


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


_________________________________________________________________
Frustrated with dial-up? Get high-speed for as low as $26.95. https://broadband.msn.com (Prices may vary by service area.)



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



Reply via email to