Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between Validation and Workflow Interceptor in Struts2

 
Naresh Shanmugam
Ranch Hand
Posts: 86
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 86
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct; that's more or less what I said.
 
Naresh Shanmugam
Ranch Hand
Posts: 86
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the clarification David
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic