You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Richard Sayre <ri...@gmail.com> on 2007/07/09 03:32:07 UTC

Control Interceptor order

I added an Interceptor locally to one of my Actions.  This Interceptor
implements SessionAware and has a setSession(Map session) method to
get the session.  The problem is when my interceptor runs session is
null.  I am assuming this is because the interceptor that populates
the session aware objects is not running before this one.  How can I
insure that my interceptor runs after the interceptor that sets the
session?
My package extends struts-default so I know that the SessionAware
interceptor should be running.  I want my Interceptor to run after the
struts-default interceptors are finished.

Here is my XML

<interceptors>
            <interceptor name="accessChecker"
class="interceptors.design.GlobalDesignAccessInterceptor"/>
</interceptors>

<global-results>
       <result name="noAccess" type="redirect-action">
         <param name="actionName">Home</param>
         <param name="namespace">/</param>
       </result>
</global-results>

<action name="selectCustomer" class="actions.design.Customer"
method="populateCustomerList">
            <interceptor-ref name="accessChecker"/>
            <result name="success">/GlobalDesign/selectCustomer.jsp</result>

</action>

I can get it to work if I get the session by using
ActionContext.getContext().getSession(); but the FAQ Question
referenced from this page
http://struts.apache.org/2.x/docs/interceptors.html called "How do we
get access to the session?" says the preferred method is to implement
SessionAware.

Thank you,

Rich

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Control Interceptor order

Posted by Chris Pratt <th...@gmail.com>.
Others should definitely correct me if I'm wrong, but interceptors don't
inject other interceptors, just actions.  If you need access to the Session,
just use the one in the ActionInvocation.
  (*Chris*)

On 7/8/07, Richard Sayre <ri...@gmail.com> wrote:
>
> I added an Interceptor locally to one of my Actions.  This Interceptor
> implements SessionAware and has a setSession(Map session) method to
> get the session.  The problem is when my interceptor runs session is
> null.  I am assuming this is because the interceptor that populates
> the session aware objects is not running before this one.  How can I
> insure that my interceptor runs after the interceptor that sets the
> session?
> My package extends struts-default so I know that the SessionAware
> interceptor should be running.  I want my Interceptor to run after the
> struts-default interceptors are finished.
>
> Here is my XML
>
> <interceptors>
>             <interceptor name="accessChecker"
> class="interceptors.design.GlobalDesignAccessInterceptor"/>
> </interceptors>
>
> <global-results>
>        <result name="noAccess" type="redirect-action">
>          <param name="actionName">Home</param>
>          <param name="namespace">/</param>
>        </result>
> </global-results>
>
> <action name="selectCustomer" class="actions.design.Customer"
> method="populateCustomerList">
>             <interceptor-ref name="accessChecker"/>
>             <result
> name="success">/GlobalDesign/selectCustomer.jsp</result>
>
> </action>
>
> I can get it to work if I get the session by using
> ActionContext.getContext().getSession(); but the FAQ Question
> referenced from this page
> http://struts.apache.org/2.x/docs/interceptors.html called "How do we
> get access to the session?" says the preferred method is to implement
> SessionAware.
>
> Thank you,
>
> Rich
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>