• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

declarative validation of wizard pages

 
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,

i have a kind of wizard: a set of pages which are all filled from the same form (a ValidatorForm) and all processed by the same action (which - if necessary - forwards the request to the appropriate special action)

i want to use declarative validation for that.

suppose i have field A on page 1, field B on page 2, let both be required.

when validation fails, the processor would normaly forward the request to the (single) page defined with the input attribute.

what i obviously want is
- if field A is missing, forward to page 1
- if field B is missing, forward to page 2

is there any way that i can achieve this declaratively?

thanks a lot,
jan
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I see it, the best way to achieve this is to create a separate action mapping for each page. Even if you are using the same Action class for every page, you can still have a separate Action mapping. example:

<action name="wizardForm" path="/Page1" type="com.mycompany.WizardAction" input="/page1.jsp" />
<action name="wizardForm" path="/Page2" type="com.mycompany.WizardAction" input="/page2.jsp"/>
<action name="wizardForm" path="/Page3" type="com.mycompany.WizardAction" input="/page3.jsp"/>

You would then have your form bean extend ValidatorActionForm instead of ValidatorForm. In the validation.xml file, you would specify the action path as the name attribute of the form tag instead of the ActionForm name. Then include only the fields processed by that action path (page).

Since there is a separate input page for each action mapping, the Validation Framework will return to the correct page if there's an error.
 
Jan Groth
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a perfect solution. thanks a alot, merrill!
 
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic