You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nicolas Pottrain <np...@reference.be> on 2003/03/20 10:24:20 UTC

Multipage Validation - Show errors on page where first action occ urs

Hi everybody,
 
I will sketch my problem:
 
I have a multi page form, that consists of 3 pages.
There are next - previous buttons to navigate between the pages, no
validation occurrs when pressing next/previous.
The user can press submit on each of the 3 pages. 
When the user presses submit, then validation occurs.
I would like the error messages to show on the page where the first error
comes from.
 
If I use the page property in the field element, only the pages up to the
current page are validated,
so that's not an option, I want everyhting to be validated.
When I don't use the page property the errors show up on the page where I
pressed submit.
 
Is there a way to show the error messages on the first page where an error
occurrs?
For ex. I press submit on page3, I get a ValidationError : a required field
not filled in on page1
Redirect to page1 and show the error messages.
 
thx,
 
Nicolas Pottrain

Re: Multipage Validation - Show errors on page where first action occurs

Posted by Nicolas De Loof <ni...@cgey.com>.
use 3 actionMapping and 1 formBean with custom validate() :

submit -> /action1.do (validate form1 parameters) input="page1"
       -> forward to
          /action2.do (validate form2 parameters) input="page2"
       -> forward to
          /action3.do (validate form3 parameters) input="page3"

/action1 and /action2 are forward mappings

/action3 uses formBean for business.

validate() uses mapping to know what property to validate. You can
extend ActionMapping to add a property "validate" that you will set in
struts-config to the comma-separated list of form properties to
validate :

<action path="/action1"
        className="myActionMapping"
        input="/page1.jsp"
        forward="/action2.do">
<set-property property="validate" value="fistname, lastname,
birthdate"/>
</action>


Hope it will help you.

Nico.

> Hi everybody,
>
> I will sketch my problem:
>
> I have a multi page form, that consists of 3 pages.
> There are next - previous buttons to navigate between the pages, no
> validation occurrs when pressing next/previous.
> The user can press submit on each of the 3 pages.
> When the user presses submit, then validation occurs.
> I would like the error messages to show on the page where the first
error
> comes from.
>
> If I use the page property in the field element, only the pages up
to the
> current page are validated,
> so that's not an option, I want everyhting to be validated.
> When I don't use the page property the errors show up on the page
where I
> pressed submit.
>
> Is there a way to show the error messages on the first page where an
error
> occurrs?
> For ex. I press submit on page3, I get a ValidationError : a
required field
> not filled in on page1
> Redirect to page1 and show the error messages.
>
> thx,
>
> Nicolas Pottrain
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org