struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Lipscombe" <>
Subject Best practice for formbean scope and handling form validation errors
Date Fri, 04 Feb 2005 16:45:45 GMT

I have 2 actions which look (sort of) like this:

<action name="myActionForm" path="/initAction" scope="request"
type="" validate="false" >
   <forward name="displayForm" path="/Form1.jsp" />

<action input="/Form1.jsp" name="myActionForm" path="/processAction"
scope="request" validate="true" >
  <forward name="nextStep" path="/Form2.jsp" />

If the Form1.jsp is submitted the "/" gets called.
Validation occurs in either the "myActionForm" actionform or the "myAction"

If the validation fails a struts ActionErrors object is populated and
Form1.jsp is re-displayed by getting the forward like this:

 forward = actionMapping.getInputForward();

But, if the scope of the "myActionForm" formbean is "request" a new instance
of the formbean is constructed when Form1.jsp is re-displayed. Hence none of
the data that it originally held in it is present and the form fails. The
formBean was originally populated by /
In order to preserve the myAction formBean I have to make its scope

I need to re-display the Form1.jsp if validation fails so that it shows the
correct formBean values as populated by / However it seems
that eventually I will have a cluttered session object with many formBeans
that I don't need immediately.

Is this normal? 
Or is there a better way to do it where one can have formBeans in "request"
scope and still preserve their contents if validation fails?
What is best practice?

TIA -Adam

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message