This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Difference between Validation and Workflow Interceptor in Struts2
Naresh Shanmugam
Ranch Hand
Joined: Jul 16, 2010
Posts: 82
posted
0
WorkFlow Interceptor does the validation by invoking the validate() method defined in the action class. Why do we have a seperate interceptor like "Validation" Interceptor. Can some body tell
1. The difference between these two interceptor
2. What sort of validation should be done with Validation/Workflow Interceptor
In our project we are using both, but not sure why.
Naresh Shanmugam wrote:WorkFlow Interceptor does the validation by invoking the validate() method defined in the action class.
That's not actually true. Validation does the validation. Workflow uses the results of validation (if any) to determine if we need to see the "input" result (by default) again. The information on the S2 wiki is incorrect (and actually contradictory) but nobody's updated it. See the source at the end of this message for further info.
In other words, using just the "validation" interceptor isn't enough, unless you're handling any errors on your own (which you could certainly do).
Note that the source for the interceptors is available, and provides a trivial answer to questions like this.
The DefaultWorkflowInterceptor is this (*heavily* edited for clarity):
Naresh Shanmugam
Ranch Hand
Joined: Jul 16, 2010
Posts: 82
posted
0
David, Please tell me if my understanding is correct.
1. Validation Interceptor does the actual validation of calling the validate() method of the action. It also adds error if there are any during validation.
2. WorkFlow Interceptor which checks for these errors, and changes the flow based on it.