Yes but...
It's my understanding that super.validate()
validates all the form's fields at once.  In the case of a 
wizard you don't have all the fields populated
by the user until they reach the last page.
I'd like to take advantage of the rules in 
validation.xml and not (re)write the code inside
the braces.

-----Original Message-----
From: Ludovic Maitre [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2003 8:34 AM
To: Struts Users Mailing List
Subject: Re: Use of Validator in a Wizard Validator


Hello,

I use do my validations in the brackets.
For example i test that a field of the form on the page 1 is valid :

//first launch automatic validation
ActionErrors errors = super.validate(mapping, request);

//second do specific validation.
if (page == 1) {
        //Check page 1 properties
        //here it test the form properties of page 1 :
        //retrieve the form and cast it appropriatly
        MyForm mf = (MyForm) form;
        //check properties
        if (dontSatisfyValidation(mf.getMyProperty())
                //add an error if the property isn't validated
                errors.add...
         else
                //add a message if validation is ok for this field
                messages.add(...
 >  }

You should have access to the Form generated from the request from the 
client and check the form properties, and your code could contain some 
functions, like dontSatisfyValidation, for verifiy that each field 
concerned by the page which is actually checked.

For automatic validation, driven by rules defined in 
validator-config.xml (or validator-rules, check the 2 files), (i think 
you think to this when you say "what is the method call I use to 
validate just a single field") you do : super.validate() on the 
beginning of your form. (which must extend ValidatorForm, check the 
Javadoc for this class).

So good luck, re-read the doc and the examples if you don't understand 
my mail,
best regards,
Ludo

Kearney, Michael wrote:
> Hmmm, no response.  Let me rephrase the question.
> 
> How do you perform field validation in your wizards?
> 
> Thanks, Michael
> 
> -----Original Message-----
> From: Kearney, Michael [mailto:[EMAIL PROTECTED]
> Sent: Monday, July 14, 2003 12:28 PM
> To: '[EMAIL PROTECTED]'
> Subject: FW: Use of Validator in a Wizard Validator
> 
> 
>  The "Struts in Action" book describes how to do multipage validations in
> chapter 12.10.1
>  by using the following code:
>  if (page == 1) {
>       //Check page 1 properties
>  }
>  if (page == 2) (
>       // And so on.
>  
>  Unfortunately, it doesn't go into detail about what goes inside the
braces.
>  What I'd like to know is what is the method call I use to validate just a
> single field so I
>  don't have to reinvent the wheel.
>  
>       Best Regards,
>                 Michael
>  
>  
>  Michael P. Kearney
>  [EMAIL PROTECTED]
>  303-444-1101 x105
>  Qualstar Corporation
>  Advanced Development
>  5480 Valmont Rd., Suite 250
>  Boulder, CO 80301-2367
> 
> ---------------------------------------------------------------------
> 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]
> 
> 
> 

-- 
Ludovic Maître

Factory Productions                 | Tél: (33) 04 93 07 08 00
149, avenue des mimosas             | Fax: (33) 04 93 07 04 02
06700 Saint-Laurent-du-Var (France) | Web: http://www.factory.fr




---------------------------------------------------------------------
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