struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: ActionForm clearing
Date Wed, 04 Oct 2000 19:53:31 GMT
Don Jones wrote:

> When using a <struts:submit>  do I need to manually clear the ActionForm
> or is there some built-in STRUTS functionality that will do this for
> me?   It is probably right in front of me and I am not seeing it.   In
> my app, after a <struts:submit> I forward back to the jsp from which
> this form can be selected again.  When selected the inputs from the
> previous entry are still in the form.

Here's how I normally handle this scenario.  In the Action class that
handles this form submit:
* Perform whatever task is requested
* Remove the form bean session attribute
* Forward to whatever JSP page is appropriate.

When the <struts:form> tag of the form sees that there is no form bean
there, it will create a new one (with whatever default values you have
defined in the class itself) and store it in the session.  From the user's
perspective, that's a new blank form.

In general, it is a good practice to delete form beans from the session when
you are through with them -- otherwise they just sit there occupying memory
until the session is invalidated or timed out.

> Cheers,
> Don Jones

Craig McClanahan

See you at ApacheCon Europe <>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat

View raw message