Do you have to issue code after the call here:  

frm.set("typeName", "xxxxx");

like: 

placeFormBackInScope( mapping, frm, request );

which would place the updated form back in scope:   

public void placeFormInScope(ActionMapping mapping, 
                             ActionForm form, 
                             HttpServletRequest request)  {
   if (mapping.getScope().equalsIgnoreCase("REQUEST") ) {
      request.setAttribute( mapping.getName(), frm );
   } else if ( mapping.getScope().equalsIgnoreCase("SESSION")) {
      HttpSession session = request.getSession();
      session.setAttribute( mapping.getName(), frm );
   }
}


-----Original Message-----
From: fea jabi [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 19, 2006 3:44 PM
To: user@struts.apache.org
Subject: form-property value set in dispatch action is lost


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.

_________________________________________________________________
Express yourself - download free Windows Live Messenger themes! 
http://clk.atdmt.com/MSN/go/msnnkwme0020000001msn/direct/01/?href=http://imagine-msn.com/themes/vibe/default.aspx?locale=en-us&source=hmtagline


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

Reply via email to