struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Jouravlev" <jmi...@gmail.com>
Subject Re: form-property value set in dispatch action is lost
Date Wed, 20 Sep 2006 22:34:46 GMT
You use the same form in both actions, and you chain them without a
redirect, so the request parameters are applied to your form again
when you forward to PrepareAction.

Struts repopulates your form with request parameters, so if the
parameter is mentioned in the request and it is emply, Struts will
clear the value you've set.

Also check your reset() method, Struts will call it before populating
the form. This method is called from both of your actions, and you
should not clear your form if PrepareAction is called.

On 9/19/06, fea jabi <zyxrm@hotmail.com> wrote:
> In struts config have a Dynavalidator form-bean
>
> <form-bean name="Form1" type=".... DynaValidatorForm">
>      <form-property name="typeName" type="java.lang.String"/>
> ......
> </form-bean>
>
> have prepare(Action) and dispath(LookupDispatchAction) actions for the jsp
> in the config which are session scoped.
>
> <action
>             path="/PrepareAction"
>             type="com.PrepareAction"
>             name="Form1"
>             scope="session">
>             <forward name="success" path="/pages/Accounts.jsp"
> redirect="false"/>
>         </action>
>
> <action
>             path="/DispatchAction"
>             type="com.DispatchAction"
>             name="Form1"
>             scope="session"
>             parameter="method">
>             <forward name="successCalc" path="/PrepareAction.do"
> redirect="false"/>
>       </action>
>
>
> In the jsp have a submit button which dispatches to the dispatch action to
> one of the methods in it.
> I am setting one of the form property value in that method.
>
>
> public class DispatchAction extends LookupDispatchAction {
>
>         protected Map getKeyMethodMap() {
>                      Map map = new HashMap();
>                      map.put("btn.calc", "calc");
>                 }
>
>                 public ActionForward calculate(ActionMapping mapping,
>                         ActionForm form,
>                         HttpServletRequest request,
>                         HttpServletResponse response)
>                         throws IOException, ServletException {
>                 DynaValidatorForm frm = (DynaValidatorForm)form;
>
>                                 frm.set("typeName", "xxxxx");
>
>                             return mapping.findForward("successCalc");
>                }
>
>      }
>
>
> setting the form-property value in the dispatch action i.e the "typeName" to
> "xxxxx"
>
> When it is sucess it is going back to the prepare action and the form
> property value is "" instead of "xxxxx". checked at the first statement in
> the execute method in prepare action the form-property value is different.
>
> not sure why the form-property value is different in prepare action as
> before. When in dispatch action the form-bean had the right value i.e the
> form-property in form-bean to "xxxxx". but when came to prepare it's value
> is lost.
>
> why is this happenning? how can this be fixed?
>
> Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message