You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by fea jabi <zy...@hotmail.com> on 2006/09/25 15:36:34 UTC
mapping forwards
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"
validate="true"
parameter="method">
<forward name="successCalc" path="/pages/Accounts.jsp"
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 calc(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
DynaValidatorForm frm = (DynaValidatorForm)form;
frm.set("typeName", "xxxxx");
return mapping.findForward("successCalc");
}
}
Have couple of buttons on the jsp. calc button which has to return to the
same jsp, and load the jsp with calculated values.
Using struts validator for validating the user inputs. Observed that the
mapping forwards when forwarded to the jsp instead of action, had to save
the token before returning the sucessCalc. Is this the right way of doing?
Have other buttons which forward to the different jsp after performing some
actions so, forwarding them to the appropriate prepare actions.
But when this page is loaded initially it should have all form bean
properties to blank/null. I know we can use reset method to do this. But how
does it effect when calc button is pressed? which comes back to the same
jsp.
What I would like to know is, how mapping forwards are handled in such
situations. Are the forwards forwarded to jsp or prepare actions? when is it
forwarded to jsp, and when to prepare actions?
Also, I need to set the form-bean values to null/blank initially and also,
when the user clicks on any other buttons except the calculate also they
have to be set to null/blank. how to do this?
Your help is appreciated.
Thanks.
_________________________________________________________________
Find a local pizza place, music store, museum and moreĀ
then map the best
route! http://local.live.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org