struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Kitchen" <jason.kitc...@s1.com>
Subject Re: Multi-page form
Date Tue, 10 Oct 2000 16:05:40 GMT
Jean-Baptiste Nizet wrote:
> 
> Jason Kitchen wrote:
> 
> > Sean Moore wrote:
> > >
> > > I also am very interested in the multipage "form".
> > >
> > > a quote from the old user manual reads:
> > > "Struts encourages you to define a single ActionForm bean that contains
> > > properties for all of the fields, no matter which page the field is
> > > actually displayed on. Likewise, the various pages of the same form
> > > should all be submitted to the same Action Class. If you follow these
> > > suggestions, the page designers can rearrange the fields among the
> > > various pages, with no changes required to the processing logic in
> > > most cases."
> > >
> > > What attracted me was the ability for designers to take my
> > > extra long one page form and turn it into as many pages as
> > > needed for normal people and not change any application logic.
> > >
> > > I have created a ActionForm called MultipageForm with all of the
> > > variables.
> > > I have created one Action called MultipageAction.
> > > I like only having one Action and only one ActionForm.
> > >
> > > My first sticking point is how do I validate the variables
> > > on just the submited page before moving to the next page?
> > > If my designers are moving things all around on
> > > different pages then how do I know which variable is on
> > > which page and when to validate it?
> > >
> > > Can someone point me in the right direction?
> > >
> > > When I get this working I would be glad to submit it as an
> > > example.
> > >
> > > Thanks,
> > > Sean
> >
> > This is something that we're trying to do now.
> > According to the struts user guide and looking at the source code
> > it appears that the developers want us to use a ValidatingActionForm.
> > Implementing the ValidatingActionForm means implementing the
> > validate method which has no parameters and hence no reference to the
> > HttpServletRequest is available to perform the validations. Since we
> > don't have access to the request how is it possible to figure out which
> > form attributes were passed to the servlet ?
> >
> 
> Hi Jason. How is it going in Charlotte? ;-)
> The reason you don't need the HttpServletRequest for the validation is plain
> simple: thanks to Struts, the parameters passed by the browser will
> automatically be in the form itself (if a corresponding setter is found,
> obviously). So, if your form is to be used in a wizard (multiple pages), just
> add a "step" field in your form and sets it to 1 when the first screen of the
> wizard is submitted (thanks to a hidden field), to 2 when the second screen is
> submitted, and so on. In your validate, just dispatch to the right
> "partialValidate" method depending on the value of the step variable. Am I
> missing something?
> 
> On the other hand, I would also like to have access to the HttpServletRequest in
> the validate method, in order to have access to other parameters in the request,
> or, more important, in the session. For example, the validate method could
> retrieve the locale of the current user in his session and validate dates,
> currencies, etc. in a locale-dependent way.
> 
> Craig, is it something you plan to offer in a future release?
> 
> >
> > May be some modifications are required to the API in order to support
> > this ?
> >
> > -- Jason
> 

Things are going well in Charlotte thanks...

I still think you're missing the point - maybe I didn't explain myself clearly.
The solution you provide above means that each time you move a field from 
"step 1 form" to "step 2 form" or vice-versa you need to modify the correct
"partialValidate" method. What I would like to do is to be able to move fields
to another form with no code impact (other than JSP). I think that this is what
the struts designers intended (comments from the struts developers ?) but
the validations are preventing the relaization of this goal.

In addition I think that this is easily achievable with a few modifications to the 
struts framework:

- Change the ValidatingActionForm interface - the signature to the validate() method 
  becomes: public String[] validate(HttpServletRequest request);

- In ActionServlet.processValidate() we need to pass the HttpServletRequest object
  as a parameter when we call the validate method.

-- Jason

Mime
View raw message