Question

I read many tutorial about interceptors. But still I am not clear about these two interceptors.

work-flow Interceptor and validation Interceptor

Which interceptor actually calls validate() method??

Which interceptor can exclude calling validate() ??

Please explain with simple example......

Thanks

Was it helpful?

Solution

  1. Validation Interceptor does the actual validation. It calls the validate() method of the action. If there are any @validation annotation or if there are any xml files (ActionClass-validation.xml) it checks these validations. It also adds error messages if there are any during validation.
  2. WorkFlow Interceptor which checks for these errors, and changes the flow based on the result of the error. You can change the default behavior of the workflow by implementing ValidationWorkflowAware or using @InputConfig annotation.

The workflow documentation is not so update, I suggest you take a look at the source of DefaultWorkflowInterceptor which is very easy to understand.

OTHER TIPS

Hello Mayur, In Struts2 validate() method in your action class extending Action Support uses work-flow Interceptor if your package extends the Strutsdefault package . validate() is implemented in ActionSupport class and when request comes first it looks validate method in your class and then workflow interceptor get executed. while validation Interceptor is used in annotation based validation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top