Reputation: 409
Is it possible in Struts 2 to make a validator annotation to invoke a given method in my action (to perform that validation there)?
Thanks in advance!
Upvotes: 1
Views: 452
Reputation: 499
I don't understand why you want to invoke a method from an annotation. You should stick to the standard
validate
or
validateMethodName
to perform custom validations. So if you have a delete
method that you want to validate the you should put the validation code in a validateDelete
method.
Upvotes: 0
Reputation: 527
the ordinary validation interceptor will invoke validate() method in your action. if what you want to do is simply doing validation inside your action class, why don't you just use the validate() method?
alternatively, you can create your own interceptor to replace the standard validator interceptor. there, use java reflection to find which method is annotated with @MyValidatorMethod, then invoke that method.
Upvotes: 1