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:[EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to