Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling an interceptor twice

 
MaheshS Kumbhar
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got to see below code on http://www.opensymphony.com/webwork/wikidocs/Prepare%20Interceptor.html




My question is, how to call same interceptor(in this case prepare interceptor) twice?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34839
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you need to call it twice? Can't you just have logic that occurs both before and after the call to proceed to further interceptors?
 
Joe Ess
Bartender
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The original poster is asking why the documentation says the interceptor is called twice with the configuration he posted (see his link).
The way I understand it, the "params" interceptor is invoked once explicitly in the configuration above, then invoked again in the "basicStack" (see the default configuration).
As to why one would do this:
A typical use of this is to run some logic to load an object from the database so that when parameters are set they can be set on this object. For example, suppose you have a User object with two properties: id and name. Provided that the params interceptor is called twice (once before and once after this interceptor), you can load the User object using the id property, and then when the second params interceptor is called the parameter user.name will be set, as desired, on the actual object loaded from the database.
 
MaheshS Kumbhar
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Joe
>>>The way I understand it, the "params" interceptor is invoked once explicitly in the configuration above, then invoked again in the "basicStack" (see the default configuration)

Your comment made me understand why the interceptor is called twice. once via explicit call and once via basicStack
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic