views:

18

answers:

2

Hi All,

I have an Action class with CRUD actions inside and I have overridden the validate() method given by the ActionSupport class.

The question is: how can I fire the validation only for the update and create actions?

One possible solution is to move create & update on a brand new Action class, but I'd like to know if there's another solution for this.

Thanks! Roberto

A: 

I believe the two options are : refactor the validatable methods into a new action (as you said), or switch to programmatic validation (instead of declarative). Basically, call myvalidate() from inside your update/create methods, and return INPUT if there are errors.

leonbloy
in the end I went for the second option, thanks
Roberto
A: 

You can exclude the other methods by putting an exclusion in your configuration file.

<interceptor-ref name="validation">
  <param name="validateAnnotatedMethodOnly">true</param>                
  <param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
ElectronicBlacksmith