*
The moose likes Struts and the fly likes Difference between Validation and Workflow Interceptor in Struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Difference between Validation and Workflow Interceptor in Struts2" Watch "Difference between Validation and Workflow Interceptor in Struts2" New topic
Author

Difference between Validation and Workflow Interceptor in Struts2

Naresh Shanmugam
Ranch Hand

Joined: Jul 16, 2010
Posts: 84
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.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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: 84
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.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Correct; that's more or less what I said.
Naresh Shanmugam
Ranch Hand

Joined: Jul 16, 2010
Posts: 84
Thank you for the clarification David
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between Validation and Workflow Interceptor in Struts2
 
Similar Threads
RedirectMessageInterceptor
input reult type in Struts2
Struts2 result code
Overriding default interceptor stack
org.apache.struts2.dispatcher.Dispatcher serviceAction Could not find action or result