You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Zakaria khabot <z....@ced.mfie.gov.ma> on 2004/04/07 12:55:54 UTC

validation.xml

Hi all,

How to call the validator from an Action.
- in struts-config I put validate="false",
- I am using validation.xml to control erors.
- In the action I wrote :            
ActionErrors errors = new ActionErrors();

errors = form.validate(mapping, request);

but it executes the validate methode in the formAction not in the validation.xml.



Thanks for help... 



Re: validation.xml

Posted by Matt Raible <li...@raibledesigns.com>.
Make sure your validate method calls super.validate() first.

Matt

On Apr 7, 2004, at 4:55 AM, Zakaria khabot wrote:

> Hi all,
>
> How to call the validator from an Action.
> - in struts-config I put validate="false",
> - I am using validation.xml to control erors.
> - In the action I wrote :
> ActionErrors errors = new ActionErrors();
>
> errors = form.validate(mapping, request);
>
> but it executes the validate methode in the formAction not in the 
> validation.xml.
>
>
>
> Thanks for help...
>
>


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


RE: validation.xml

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
did you subclass from ValidatorForm
instead of ActionForm ?

cheers

-----Original Message-----
From: Zakaria khabot [mailto:z.khabot@ced.mfie.gov.ma] 
Sent: Wednesday, April 07, 2004 12:56 PM
To: Struts Users Mailing List; Struts Developers List
Subject: validation.xml


Hi all,

How to call the validator from an Action.
- in struts-config I put validate="false",
- I am using validation.xml to control erors.
- In the action I wrote :            
ActionErrors errors = new ActionErrors();

errors = form.validate(mapping, request);

but it executes the validate methode in the formAction not in the
validation.xml.



Thanks for help... 




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


RE: validation.xml

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
did you subclass from ValidatorForm
instead of ActionForm ?

cheers

-----Original Message-----
From: Zakaria khabot [mailto:z.khabot@ced.mfie.gov.ma] 
Sent: Wednesday, April 07, 2004 12:56 PM
To: Struts Users Mailing List; Struts Developers List
Subject: validation.xml


Hi all,

How to call the validator from an Action.
- in struts-config I put validate="false",
- I am using validation.xml to control erors.
- In the action I wrote :            
ActionErrors errors = new ActionErrors();

errors = form.validate(mapping, request);

but it executes the validate methode in the formAction not in the
validation.xml.



Thanks for help... 




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


Re: validation.xml

Posted by Zakaria khabot <z....@ced.mfie.gov.ma>.
Hi all,
I start runnig my application with an Action (action.do) which access to the
database to get a collection and send it to the JSP.
The problem is : when I put validate ="true" in struts-config an error is
detected (because fields in the JSP are blank) so the collection is null and
the JSP is not displayed.
The solotion I want : to display the JSP with errors, and also the
collection(not null).
Thanks....

----- Original Message -----
From: "Matthias Wessendorf" <ma...@matthias-wessendorf.de>
To: "'Struts Developers List'" <de...@struts.apache.org>;
<am...@sanchezindia.com>
Sent: Wednesday, April 07, 2004 11:37 AM
Subject: RE: validation.xml


> i suggest you to use ActionMessage,
> since ActionError is deprecated.
>
> and ActionErrorS is only used in
> ActionForm.valdiate();
>
> however, why are we talking in struts-dev
> on such a common thing ? :-)
>
> Cheers!
> Matthias
>
> -----Original Message-----
> From: Amiya Moharana [mailto:amoharana@sanchezindia.com]
> Sent: Wednesday, April 07, 2004 1:30 PM
> To: Struts Developers List
> Subject: RE: validation.xml
>
>
> Hi Zakaria,
>
>   Generally validator is called before the form is submitted to any
> ActionClasses. Just check the sequence of events when we submitt our
> form. The order is like this when we submit the form:
>
> 1: It goes and checks for any instances of the bean in the current
> specified scope( the name of the class, type, and scope is got from the
> struts-config.xml).
> 2: If found then call the reset method on it.
> 4: If not found than a new instanc is created and stored in the proper
> scope.
> 5: Then the formBean is populated.
> 6: If the validate is true than the validate() method is get
> called(autometically called, no need to call it explicitly.)
> 7: Than it checks for the action to which the form is to be submitted.
>
> Common validation like: checking an integer, Date, floating point
> number, not null are done with the help of validation.xml file. If you
> need more specific validation you can put it in the validate() method.
> If some more business logic related validations (like loggin, pw checks)
> are needed than put these type of validation in the action classes.
> Whenever there is some validation fails create a ActionError and add it
> ActionErrors objects, and save it to request so that it can be shown to
> the user.
>
>  When you are putting the logic in the validate method there is no need
> to call it explicitly as you have done "form.validate(mapping,
> request);". It is autometically get called on the form instance, as
> mentioned in the sequence.
>
> With Warm Regards.
> Amiya.
>
>
>
> -----Original Message-----
> From: Zakaria khabot [mailto:z.khabot@ced.mfie.gov.ma]
> Sent: Wednesday, April 07, 2004 4:26 PM
> To: Struts Users Mailing List; Struts Developers List
> Subject: validation.xml
>
>
> Hi all,
>
> How to call the validator from an Action.
> - in struts-config I put validate="false",
> - I am using validation.xml to control erors.
> - In the action I wrote :
> ActionErrors errors = new ActionErrors();
>
> errors = form.validate(mapping, request);
>
> but it executes the validate methode in the formAction not in the
> validation.xml.
>
>
>
> Thanks for help...
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>



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


RE: validation.xml

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
i suggest you to use ActionMessage,
since ActionError is deprecated.

and ActionErrorS is only used in
ActionForm.valdiate();

however, why are we talking in struts-dev
on such a common thing ? :-)

Cheers!
Matthias

-----Original Message-----
From: Amiya Moharana [mailto:amoharana@sanchezindia.com] 
Sent: Wednesday, April 07, 2004 1:30 PM
To: Struts Developers List
Subject: RE: validation.xml


Hi Zakaria,

  Generally validator is called before the form is submitted to any
ActionClasses. Just check the sequence of events when we submitt our
form. The order is like this when we submit the form:

1: It goes and checks for any instances of the bean in the current
specified scope( the name of the class, type, and scope is got from the
struts-config.xml).
2: If found then call the reset method on it.
4: If not found than a new instanc is created and stored in the proper
scope.
5: Then the formBean is populated.
6: If the validate is true than the validate() method is get
called(autometically called, no need to call it explicitly.)
7: Than it checks for the action to which the form is to be submitted.

Common validation like: checking an integer, Date, floating point
number, not null are done with the help of validation.xml file. If you
need more specific validation you can put it in the validate() method.
If some more business logic related validations (like loggin, pw checks)
are needed than put these type of validation in the action classes.
Whenever there is some validation fails create a ActionError and add it
ActionErrors objects, and save it to request so that it can be shown to
the user.

 When you are putting the logic in the validate method there is no need
to call it explicitly as you have done "form.validate(mapping,
request);". It is autometically get called on the form instance, as
mentioned in the sequence.

With Warm Regards.
Amiya.



-----Original Message-----
From: Zakaria khabot [mailto:z.khabot@ced.mfie.gov.ma]
Sent: Wednesday, April 07, 2004 4:26 PM
To: Struts Users Mailing List; Struts Developers List
Subject: validation.xml


Hi all,

How to call the validator from an Action.
- in struts-config I put validate="false",
- I am using validation.xml to control erors.
- In the action I wrote :
ActionErrors errors = new ActionErrors();

errors = form.validate(mapping, request);

but it executes the validate methode in the formAction not in the
validation.xml.



Thanks for help...




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


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


RE: validation.xml

Posted by Amiya Moharana <am...@sanchezindia.com>.
Hi Zakaria,

  Generally validator is called before the form is submitted to any
ActionClasses. Just check the sequence of events when we submitt our form.
The order is like this when we submit the form:

1: It goes and checks for any instances of the bean in the current specified
scope( the name of the class, type, and scope is got from the
struts-config.xml).
2: If found then call the reset method on it.
4: If not found than a new instanc is created and stored in the proper
scope.
5: Then the formBean is populated.
6: If the validate is true than the validate() method is get
called(autometically called, no need to call it explicitly.)
7: Than it checks for the action to which the form is to be submitted.

Common validation like: checking an integer, Date, floating point number,
not null are done with the help of validation.xml file. If you need more
specific validation you can put it in the validate() method. If some more
business logic related validations (like loggin, pw checks) are needed than
put these type of validation in the action classes. Whenever there is some
validation fails create a ActionError and add it ActionErrors objects, and
save it to request so that it can be shown to the user.

 When you are putting the logic in the validate method there is no need to
call it explicitly as you have done "form.validate(mapping, request);". It
is autometically get called on the form instance, as mentioned in the
sequence.

With Warm Regards.
Amiya.



-----Original Message-----
From: Zakaria khabot [mailto:z.khabot@ced.mfie.gov.ma]
Sent: Wednesday, April 07, 2004 4:26 PM
To: Struts Users Mailing List; Struts Developers List
Subject: validation.xml


Hi all,

How to call the validator from an Action.
- in struts-config I put validate="false",
- I am using validation.xml to control erors.
- In the action I wrote :
ActionErrors errors = new ActionErrors();

errors = form.validate(mapping, request);

but it executes the validate methode in the formAction not in the
validation.xml.



Thanks for help...




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


Problem with struts validator

Posted by Marco Mistroni <mm...@waersystems.com>.
Hi all,
	I am experiencing problems with struts-validator, in that it
seems
That the validation is not done at all.
I have created a form (named contactFomr) that extends
DynaValidatorForm.

<form-bean name="contactForm"
type="org.apache.struts.validator.DynaValidatorForm">		
			 <form-property name="contactRef"
type="java.lang.String"/>
		     <form-property name="contactName"
type="java.lang.String"/>
		     <form-property name="address1"
type="java.lang.String"/>
		     <form-property name="address2"
type="java.lang.String"/>
		     <form-property name="address3"
type="java.lang.String"/>
		     <form-property name="address4"
type="java.lang.String"/>
		     <form-property name="postcode"
type="java.lang.String"/>
		     <form-property name="fax" type="java.lang.String"/>
		     <form-property name="country"
type="java.lang.String"/>
		     <form-property name="emailAddress"
type="java.lang.String"/>
		     <form-property name="website"
type="java.lang.String"/>
		     <form-property name="telephohe"
type="java.lang.String"/>
		     <form-property name="version"
type="java.lang.Integer"/>
		     <form-property name="versionDate"
type="java.sql.Timestamp"/>
		     <form-property name="buttonSelected"
type="java.lang.String"/>
		     <form-property name="statusMessage"
type="java.lang.String"/>
		</form-bean>


I have created a validation.xml file which contains following code

<form-validation>


    <!-- ========== Default Language Form Definitions
===================== -->
    <formset>
       
       <!-- Validation rules for Contact form. We need to check
            only that contactRef is present
       -->
        <form name="contactForm">

            <field property="contactRef"
                    depends="required,minlength">
                  <var>
                    <var-name>minlength</var-name>
                    <var-value>5</var-value>
                  </var>  
                
                <!--   
                <msg 
                	name="required"
                	key="message.00042"/>-->
            </field>

            
        </form>

    </formset>


</form-validation>


I have configured the plugIn In struts-config.xml ,  but whenever I
submit the form (not providing the field contactRef) everything is fine
and the form is submitted (while I was expecting to receive an error
displayed on my
Input page..)

Anyone can help?

Thanx in advance and regards
	marco







-----Original Message-----
From: Zakaria khabot [mailto:z.khabot@ced.mfie.gov.ma] 
Sent: 07 April 2004 11:56
To: Struts Users Mailing List; Struts Developers List
Subject: validation.xml

Hi all,

How to call the validator from an Action.
- in struts-config I put validate="false",
- I am using validation.xml to control erors.
- In the action I wrote :            
ActionErrors errors = new ActionErrors();

errors = form.validate(mapping, request);

but it executes the validate methode in the formAction not in the
validation.xml.



Thanks for help... 




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