Title: Message
The 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 after

the 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 Interceptors

See 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 Interceptors

I have an action chain that implements a three phase process - Update, Read, Render
 
I have two actions PhaseOneAction and PhaseTwoAction, and a JSP view
I have two interceptors SessionInterceptor and TransactionInteceptor.
 
I want to achieve one of the following nestings
 
SessionInterceptor.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()?
 
or
 
SessionInterceptor.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 achieve
 
SessionInterceptor.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.

Reply via email to