You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rick Schumeyer <rs...@ieee.org> on 2006/12/09 19:29:53 UTC

Action maps back to same page...best way to reset ActionForm?

I have jsp containing a form to add employees.  This submits to an 
action that adds the new employee to the database, and then forwards 
back to the add employee page so that more employees can be added.  
Currently, when I get back to the jsp the ActionForm still contains the 
original data, but at this point I want a blank action form.

If I am using an ActionForm (as opposed to a DynaActionForm), what is 
the best way to clear the form?
*  I can manually clear all the fields in the action before calling 
findForward
* Should I override the ActionForm reset method (and call reset before 
findForward) ?
* Should I use a DynaActionForm instead?  (Would that provide any advantage)
* Is there some other obvious solution that I'm missing?

BTW, this is struts 1.3.5.  The action configuration declares request scope.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Action maps back to same page...best way to reset ActionForm?

Posted by Christopher Goldman <cg...@dhapdigital.com>.
On Sat, 2006-12-09 at 13:29 -0500, Rick Schumeyer wrote:
> I have jsp containing a form to add employees.  This submits to an 
> action that adds the new employee to the database, and then forwards 
> back to the add employee page so that more employees can be added.  
> Currently, when I get back to the jsp the ActionForm still contains the 
> original data, but at this point I want a blank action form.
> 
> If I am using an ActionForm (as opposed to a DynaActionForm), what is 
> the best way to clear the form?
> *  I can manually clear all the fields in the action before calling 
> findForward
> * Should I override the ActionForm reset method (and call reset before 
> findForward) ?
> * Should I use a DynaActionForm instead?  (Would that provide any advantage)
> * Is there some other obvious solution that I'm missing?
> 
> BTW, this is struts 1.3.5.  The action configuration declares request scope.

Rick,

If you perform a redirect instead of a forward from the action, the new
page will have a new form, because the data will not carry over (because
you are using request scope).

As a bonus, if the user reloads the page, they will not be resubmitting
the form post that adds an employee.

Chris

-- 
Christopher D. Goldman
cgoldman@dhapdigital.com



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org