struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ben Anderson" <stuts_anderson...@hotmail.com>
Subject Re: Best Practices in Struts for Form objects?
Date Thu, 06 Nov 2003 15:56:26 GMT
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" <mic@bendcable.com>
>Reply-To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
>To: <struts-user@jakarta.apache.org>
>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: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>

_________________________________________________________________
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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message