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" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
To: "Struts Users Mailing List" <user@struts.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.
On 9/19/06, fea jabi <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________
Add fun gadgets and colorful themes to express yourself on Windows Live
Spaces
http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://www.get.live.com/spaces/features
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]