Java

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • form-property value set in dispatch action is lost

    0 answers - 4565 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    thanks a lot that worked. I never understood what the "redirect" does until
    now. I know now when to make it true.
    Thanks a lot again.

    >From: "Michael Jouravlev" <jmikus (AT) gmail (DOT) com>
    >Reply-To: "Struts Users Mailing List" <user (AT) struts (DOT) apache.org>
    >To: "Struts Users Mailing List" <user (AT) struts (DOT) apache.org>
    >Subject: Re: form-property value set in dispatch action is lost
    >Date: Wed, 20 Sep 2006 15:34:46 -0700
    >
    >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.
    >

    9/19/06, fea jabi <zyxrm (AT) hotmail (DOT) comwrote:
    >>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 IException, 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 (AT) struts (DOT) apache.org
    >For additional commands, e-mail: user-help (AT) struts (DOT) apache.org
    >

    Add fun gadgets and colorful themes to express yourself on Windows Live
    Spaces
    To unsubscribe, e-mail: user-unsubscribe (AT) struts (DOT) apache.org
    For additional commands, e-mail: user-help (AT) struts (DOT) apache.org

Re: form-property value set in dispatch action is lost


max 4000 letters.
Your nickname that display:
In order to stop the spam: 3 + 2 =
QUESTION ON "Java"

EMSDN.COM