You can use the flow:

POPULATE1-> JSP1 -> ACTION1 -> POPULATE2 -> JSP2 -> ACTION2 -> POPULATE3 -> JSP3

All of the POPULATE actions have "validate=false" in the config. So, if
validation fails after JSP2 is submitted, it forwards to POPULATE2 (ACTION2 has
input="POPULATE2" set), which won't try to validate. It makes for more (2x!)
actions, but also groups actions logically. POPULATE2 gets things ready for
JSP2, and ACTION2 does something with the form from JSP2, and doesn't care about
JSP3 at all. That way, you can move the xxx2 page somewhere else, and just have
to change the mapping in the config (assuming they're not named 1, 2, 3, that
could get a little confusing).

Not sure you'd want to change things at this point, but that's one way to
approach the problem.

Q

> -----Original Message-----
> From: Jakub Milkiewicz [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, May 07, 2006 2:14 PM
> To: Struts Users Mailing List
> Subject: Re: page validation in wizzard app
> 
> 
> Hi Richard.
> I can't because of autovalidation. Remember that all my 
> action have the same
> actionForm which is storred in session.
> If validation fails i am forwarded to previous action but 
> this action is not
> even executed cause before this previous action can be 
> invoked validation
> process occurs. Page parameter isn't changed and validation 
> process fails
> again...
> If validation fails i do not enter any action's execute() method.
> 
> 2006/5/7, Richard Yee <[EMAIL PROTECTED]>:
> >
> > Jakub,
> > Why can't you reset the page attribute to the appropriate 
> value in your
> > Action classes when validation fails.
> >
> > -Richard
> >
> > Richard Yee wrote:
> > > Jakub,
> > > I think the more elegant solution is to do the validations in the
> > > ActionForm validate method and also use a hidden static  'page'
> > > variable in the JSP. Your Action.execute method should be 
> fairly small
> > > and mainly have code that calls business delegates and 
> that necessary
> > > for determining where to forward to.
> > >
> > > -Richard
> > >
> > >
> > > Jakub Milkiewicz wrote:
> > >> Hi
> > >> I have a wizzard application with 5 screens. All user inputs are
> > >> collected
> > >> in one bean, which is named: viewBean and is stored in 
> HTTP session.
> > >> So each action has the same formBean - viewBean.
> > >> I use commons-validator and viewBean properties to validate are
> > >> present in
> > >> validation.xml with page attributes.
> > >> ViewBean extends ValidatorForm and it's validation occurs
> > >> automatically - i
> > >> have validation set to true for all ACTIONS.
> > >> The structure of my app is:
> > >> Populate view  -> jsp ->populate view ->jsp ->populate 
> view -> jsp ...
> > >> Population of view happens in ACTION class and can consists of
> > >> retrieving
> > >> some data from DB, sets these data in HTTP request.
> > >> After population process i forward to appropriate jsp to 
> give user a
> > >> chance
> > >> to fill the form and to present population process results as for
> > >> example
> > >> options in <html:select>.
> > >> If form is correct i go to another action which populate 
> view for a
> > next
> > >> screen (jsp).
> > >> If form is not filled correctly i need to show it again, 
> but i can not
> > >> forward to jsp - i need to forward to action that 
> prepares the form -
> > >> that's
> > >> why i have my input parameter of <action> tag set to action which
> > >> populate
> > >> the view - previous action.
> > >> I have a problem with page attribute. Please take a look at the
> > >> sample of
> > >> processing in my app:
> > >> ACTION1 -> JSP1 ->ACTION2 -> JSP2  ->Action3 ->JSP3 ...
> > >> Let's assume that user submits form in JSP2 to action3. After
> > ActionForm
> > >> bean population, page property is set to 2. Next, 
> validation fails in
> > >> Action3 and input parameter of <action3> forwards user 
> to ACTION2.
> > >> Before execute method in Action2 is invoked, ActionForm 
> (viewBean)
> > >> validation occurs. The page attribute is still set to 2 ! and
> > >> commons-validator tries to validate properties that has page
> > >> attribute set
> > >> to 2.Obviously validation fails and control is forwarded 
> to Action1.
> > >> Action1
> > >> also has validation set to true and validation of 
> ActionForm occurs
> > >> again
> > >> with page =2.
> > >> Validation fails and control is forwarded to ...
> > >> Does anyone have any idea to solve the problem.
> > >> My idea is to not to use hidden page parameter in each 
> jsp action but
> > >> set
> > >> page property of viewBean in each Action: for ACTION2 sets it to
> > 2,  for
> > >> Action3 sets it to 3 ...
> > >> and to override validate method in viewBean:
> > >>
> > >> public ActionErrors validate(
> > >>        ActionMapping mapping,
> > >>        HttpServletRequest request) {
> > >>        ActionErrors errors = super.validate(mapping,request);
> > >>        if(errors != null && errors.size() > 0 )
> > >>               page--;
> > >>        return errors;
> > >> }
> > >>
> > >> Maybe someone knows more elegant solution, or maybe 
> architecture of
> > >> my app
> > >> isn't valid.
> > >>
> > >
> > >
> > > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to