struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jean-Baptiste Nizet" <jean-baptiste.ni...@s1.com>
Subject Re: Multi-page form
Date Tue, 10 Oct 2000 15:29:40 GMT


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

--
Jean-Baptiste Nizet
jean-baptiste.nizet@s1.com

R&D Engineer, S1 Belgium
Kleine Kloosterstraat, 23
B-1932 Sint-Stevens Woluwe
+32 2 200 45 42



Mime
View raw message