struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alireza Fattahi <afatt...@yahoo.com.INVALID>
Subject Re: Struts 2 manually call a custom validation in an action
Date Wed, 15 Apr 2015 03:27:50 GMT
Please see: http://stackoverflow.com/questions/29603916/struts-2-manually-call-a-custom-validation-in-an-action ~Regards,
~~Alireza Fattahi
      From: Alireza Fattahi <afattahi@yahoo.com.INVALID>
 To: Struts Mailing List <user@struts.apache.org> 
 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. 

    @Validations( 
        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
            if(username.equals("")){
                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
here
 ~Regards,
~~Alireza Fattahi

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