[STRUTS question] Validation, Input, and Wizards

B

Bernie Wieser

We are using the STRUTS validator on a project that allows a user to
registered themselves through a wizard. That means they step through
eigh forms (JSP pages) that are backed onto one Action/ActionForm
class.

Now, we set the page property on the JSP page, and in the validator,
but the problem we have is that any error will take use to the
input page as defined in the struts-config.xml action mappings - which
is the first page.

At first I assumed (incorrectly) that if the validator failed, and
there
was no input attribute, I would
be redirected back to the page I was forwarded to. This isn't so, as
supposedly the input attribute must be present for validation to
happen.

So then I thought I could set input="myaction.do"...

Does anyone have and example of how to use the page attribute from
validator
forms with multiple input pages? Or a suggestion of a good scheme to
have errors directed back to the page they came from (and still use a
single Action/Form)?

Cheers,
Bernie Wieser
 
B

Bernie Wieser

[snip]
Does anyone have and example of how to use the page attribute from
validator
forms with multiple input pages? Or a suggestion of a good scheme to
have errors directed back to the page they came from (and still use a
single Action/Form)?

So... I checked the FAQ and it suggested setting up multiple
action paths for wizards sharing a single form. But what the FAQ
didn't say is that scope for the form needs to be session.
In addition, validate can't be true, because any previous
button would validate the current page before returning... so in
response to the perform/execute, I need to validate explicitly on
the next button. And then, on any cancel/done button, I need to
remove the form from session scope after I've done my thing with it.

Sample from struts-config.xml

<action path="/public/template/wizard1"
type="com.myco.template.WizardAction"
name="wizardForm"
validate="false"
parameter="method"
input="/public/template/wizard1.jsp"
scope="session">

<forward name="next" path="/public/template/wizard2.jsp"/>
</action>

<action path="/public/template/wizard2"
type="com.myco.template.WizardAction"
name="wizardForm"
validate="false"
parameter="method"
input="/public/template/wizard2.jsp"
scope="session">

<forward name="prev" path="/public/template/wizard1.jsp"/>
<forward name="next" path="/public/template/wizard3.jsp"/>
</action>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top