struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alireza Fattahi <>
Subject Re: Struts 2 manually call a custom validation in an action
Date Wed, 15 Apr 2015 03:27:50 GMT
Please see: ~Regards,
~~Alireza Fattahi
      From: Alireza Fattahi <>
 To: Struts Mailing List <> 
 Sent: Monday, 13 April 2015, 16:40
 Subject: Struts 2 manually call a custom validation in an action
We have used struts 2 validation with lots of custom validation to validate our forms. 

        customValidators =      
               { @CustomValidator(type = "AccountFormat", fieldName = "accountNo")

Also we can can manually validate a form by overriding the validate method

     public void validate(){
            //Username can't be blank
                addFieldError("username", "The Username can't be empty");

Is it possible to call the `custom validations` in the `validate()`.

**Why we need it ?!**
All validation rules are packed in custom validations, which is perfect. There are some few
forms which need to have their own manual validation. We end up cut and pasting some of custom
validation rules in these manual validation forms too, it would be best if we could call validations
~~Alireza Fattahi

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message