-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jason Carreira
Sent: Wednesday, 16 July 2003 5:50 AM
To: [EMAIL PROTECTED]
Subject: RE: [OS-webwork] WebWork2 Action Chains and InterceptorsYou can apply interceptors to the Action you're chaining TO, as well as the Action you're chaining FROM, which can also access the ValueStack, as it's passed along. You could, alternatively, put your transaction in a ThreadLocal of the TransactionInterceptor... this ThreadLocal would be available to the TransactionInterceptor of the chained Action as well. Make sure you clean them up :-)I kind of like the fact that you can wrap displaying a page to the user as part of a transaction :-)Jason-----Original Message-----
From: Cameron Braid [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2003 3:33 PM
To: [EMAIL PROTECTED]
Subject: RE: [OS-webwork] WebWork2 Action Chains and InterceptorsThe problem with the approach that you have specified is that when a action chain is used, the after calls aren't being made until after the result has executed, therefore there are no hooks to play with between the actions :
<action name="HomeUpdate" class="com.lwl.action.update.pub.HomeUpdateAction">
<result name="success" type="chain">
<param name="actionName">Home</param>
</result>
<interceptor-ref name="echo">
<param name="name">update session</param>
</interceptor-ref>
<interceptor-ref name="echo">
<param name="name">update transaction</param>
</interceptor-ref>
</action><action name="Home" class="com.lwl.action.view.pub.HomeAction">
<result name="success" type="dispatcher">
<param name="location">/WEB-INF/views/pub/Home.jsp</param>
</result>
<interceptor-ref name="echo">
<param name="name">view session</param>
</interceptor-ref>
</action>when calling UpdateHome.action I get :
update session before
update transaction before
update execute
view session before
view execute
start jsp
end jsp
view session after
update transaction after
update session afterthe only way that I can end the transaction before "view execute" woud be in "view session before" and that is a "Bad Idea (tm)"
I can get my actions to manage transactions, but isn't that what containers are for :)
I want to have 'update' actions and 'view' actions, and the update actions run within a transaction container (interceptor) therefore the action implementor only needs to wory about transactions under certain conditions. I can have a default 'commit' policy, with rollback on exception, and if the action wants to commit and throw an exception, a special DoCommitException(Exception) can be thrown, caught , unwrapped and re thrown by the container (interceptor).
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jason Carreira
Sent: Wednesday, 16 July 2003 4:48 AM
To: [EMAIL PROTECTED]
Subject: RE: [OS-webwork] WebWork2 Action Chains and InterceptorsSee below-----Original Message-----
From: Cameron Braid [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2003 2:35 PM
To: [EMAIL PROTECTED]
Subject: [OS-webwork] WebWork2 Action Chains and InterceptorsI have an action chain that implements a three phase process - Update, Read, RenderI have two actions PhaseOneAction and PhaseTwoAction, and a JSP viewI have two interceptors SessionInterceptor and TransactionInteceptor.I want to achieve one of the following nestingsSessionInterceptor.before()TransactionInterceptor.before()PhaseOneAction.execute()TransactionInterceptor.after()PhaseTwoAction.execute();SessionInterceptor.after()You could achieve this by making your Interceptors a little crafty... The SessionInterceptor is already in place... you just need to parameterize your TransactionInterceptor as to whether to process on before, after, or both. Then, on the first action, you have it process before, and on the second, you have it process on after. I think this is probably not a Good Thing (tm), since it depends on the chaining, but it would work. Alternately, you could have the TransactionInterceptor, in the after call, look for the Transaction in the ActionContext or request, or wherever and use it if it's there or skip processing if it's not, then remove it once it's done. A little less hacky. Can't you just have your Action class itself handle the transaction in the execute()?orSessionInterceptor.before()TransactionInterceptor.before()PhaseOneAction.execute()TransactionInterceptor.after()SessionInterceptor.after(){note: I don't want a client redirect here}SessionInterceptor.before()PhaseTwoAction.execute();ServletDispatcher.processPage();SessionInterceptor.after()however, currently I am only able to achieveSessionInterceptor.before()TransactionInterceptor.before()PhaseOneAction.execute()PhaseTwoAction.execute();ServletDispatcher.processPage();TransactionInterceptor.after()SessionInterceptor.after()I also would like to be able to specify that the action state is coppied from PhaseOneAction to PhaseTwoAction in the same way that the chaining process currently happens.Anyone have any ideas ?Cameron.
Title: Message
I am using a
threadlocal for both the session and transaction objects.
The issue
- which you seem to have missed - is that the chained FROM action's
interceptors are executed around the chained TO action.
This happens
because the chain is implemented as a result which is a part of the chained FROM
action's invocation.
I will just adopt
object orientation once again .. how about that eh ! and use a superclass
to implement the transaction container.
- [OS-webwork] WebWork2 Action Chains and Interceptors Cameron Braid
- Re: [OS-webwork] WebWork2 Action Chains and Intercepto... Heng Sin Low
- RE: [OS-webwork] WebWork2 Action Chains and Intercepto... Jason Carreira
- RE: [OS-webwork] WebWork2 Action Chains and Interc... Cameron Braid
- RE: [OS-webwork] WebWork2 Action Chains and Intercepto... Jason Carreira
- RE: [OS-webwork] WebWork2 Action Chains and Interc... Cameron Braid
- RE: [OS-webwork] WebWork2 Action Chains and Intercepto... Jason Carreira
- RE: [OS-webwork] WebWork2 Action Chains and Interc... Cameron Braid
- Re: [OS-webwork] WebWork2 Action Chains and Interc... Pat Lightbody
- RE: [OS-webwork] WebWork2 Action Chains and Intercepto... Jason Carreira
- RE: [OS-webwork] WebWork2 Action Chains and Interc... Heng Sin Low
- Re: [OS-webwork] WebWork2 Action Chains and Interc... Pat Lightbody
- RE: [OS-webwork] WebWork2 Action Chains and Intercepto... Jason Carreira
- RE: [OS-webwork] WebWork2 Action Chains and Intercepto... Jason Carreira