If you are using the ValidatorForm, another good trick is to key off the page property it provides.
In the reset function, put in a wrapper like this: if (getPage()==0) { setForward(null); setName(null); setTelephone(null); setNumber(null); }; This will keep the fields from being reset when you are in "Wizard" mode and using multiple pages. You can also use it to provide a quick and easy readonly mode. Just call setPage(1); in your Action before forwarding it. Also works great in the Config if you are relaying actions. Just pass ?page=1 as part of the URI. -T. Ted Husted wrote: > > If you are forwarding from Action to Actoin, the ActionServlet will > handle each request the same as the first. > > If you do not want your ActionForm to be repopulated from the request as > you forward it around, the workaround is to put an readonly property on > the form. The public setters for your properties can then check this to > see if they should allow changes or not. The first action can then set > the ActionForm to readonly before forwarding it along. > > public void setProperty(String property) { > if (isMutable()) { > this.property = property; > } > } > > There's a "SuperForm" class in the Scaffold package in the contrib > folder that demonstrates this and some other techniques > [org.apache.scaffold.http.SuperForm]. > > -- Ted Husted, Husted dot Com, Fairport NY USA. > -- Java Web Development with Struts. > -- Tel +1 585 737-3463. > -- Web http://www.husted.com/struts/ > > "Kearfott, David (DST-CLT)" wrote: > > > > Has anyone ever noticed the "Set" methods in the ActionForm invoked multiple > > times (always using the values submitted from the html:form) from Action to > > Action? > > > > In our JSP, we have several buttons pertaining to the same form > > ("thisActionForm"). Depending on which button was pressed, a different > > action mapping is invoked from Struts: > > > > <action path="/handleButtons" type="HandleButtonsAction" > > name="thisActionForm" validate="false" scope="session" input="/home.jsp"> > > <forward name="updateDetailsButton" > > path="/updateDetails.do"/> > > <forward name="resetDetailsButton" > > path="/resetDetails.do"/> > > <forward name="calculateButton" > > path="/calculateAmounts.do"/> > > <forward name="deleteButton" > > path="/deleteDetails.do"/> > > </action> > > > > <action path="/resetDetails" type="ResetDetailsAction" name="thisActionForm > > " validate="false" scope="session" input="/home.jsp"> > > <forward name="success" > > path="/calculateAmounts.do"/> > > </action> > > <action path="/calculateAmounts" type="CalculateAmountsAction" > > name="thisActionForm " validate="false" scope="session" input="/home.jsp"> > > <forward name="success" path="/details.jsp"/> > > </action> > > > > We see the fields entered/changed in "thisActionForm" set before entering > > the "HandleButtonsAction" class. > > We also see the same field values set again before entering the > > "ResetDetailsAction" class, as if the HTML form has been submitted a second > > time. > > The "ResetDetailsAction" resets some date fields on "thisActionForm", by > > invoking various Set methods. > > We then see the original field values set a third time before entering the > > "CalculateAmountsAction" class, clearing out the values reset in the > > "ResetDetailsAction" > > > > As anyone seen anything similar? > > Is there an attribute we could use in the action element that would disallow > > the form from submitting again and again and again? > > > > Our current work around is to not use "thisActionForm" on any other actions, > > except the "HandleButtonsAction", and just grab "thisActionForm" off of the > > session in "ResetDetailsAction" and "CalculateAmountsAction", but we feel > > that there's an easier way. > > > > Sorry for the novel... > > -dave kearfott > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- Ted Husted, Husted dot Com, Fairport NY USA. -- Java Web Development with Struts. -- Tel +1 585 737-3463. -- Web http://www.husted.com/struts/ -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>