In your example below, you need to call super.validate(...) in the
overridden validate method so that the validate method in ValidatorForm is
called. The validate method in ValidatorForm is the one that does the form
validation based on validation.xml and validator-rules.xml.
Here is an example of how you could add your own errors to the errors
returned by Struts validation:
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = super.validate(mapping, request);
// Do some custom processing and add errors to the "errors" variable
return errors;
}
----- Original Message -----
From: "Pani, Gourav" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, January 16, 2003 11:56 AM
Subject: Using validate() along with commons-validator
> I am not using DynaForms currently. If I stay with my Form beans
extending
> ValidatorForm, is there any way to call the validate() method and use the
> validator.xml at the same time.
>
> For example, I have the following Form bean.
>
> public class LoginForm
> extends ValidatorForm
> implements GlobalConstants
> {
> }
>
>
> I have validation for username and password in the validator.xml.
However,
> I plan on handling redirects if they are passed in as a parameter in the
URL
> query. The validation for this may be a little more complicated and I
> wanted to handle it in the validate() method. However, if I create an
> ActionErrors object in the validate() method, all errors reported by the
> validation.xml and validation-rules.xml is erased as a new ActionErrors
> object is assigned to the HttpRequest. Is there any way to append to the
> ActionErrors object if one already exists? I tried the following but it
> didn't work.
>
> public ActionErrors validate(ActionMapping mapping, HttpServletRequest
> request)
> {
> ActionErrors errors = (ActionErrors)
> request.getAttribute(ActionErrors.GLOBAL_ERROR);
>
> if (errors == null)
> {
> errors = new ActionErrors();
> }
> /*
>
> URL redirect validation done here and errors assigned as necessary.
>
> */
>
> return errors;
> }
>
> Any suggestions or is the best way just writing my own Validator class for
> the application?
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.435 / Virus Database: 244 - Release Date: 1/2/2003
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>