I think the goal was to do the check after the action executes, though--if
not, then yep, just doing it before the invocation is enough.

If the check needs to happen between action invocation and the JSP
rendering, then the interceptor should implement a PreResultListener, which
is called after invocation, but before JSP rendering.

Dave

On Wed, Nov 16, 2011 at 2:41 PM, Bruno Klava <bkl...@gmail.com> wrote:

> How about setting your object in session before the action invocation,
> i.e, before actionInvocation.invoke()?
>
> Bruno
>
> On Wed, Nov 16, 2011 at 4:09 PM, Jyothrilinga Rao <jyoth...@gmail.com>
> wrote:
> > Hi,
> >
> > I have the following configuration snippet in my struts.xml:
> >
> >
> > <package name=*"default"* namespace=*"/"* extends=*"struts-default"*>
> >  <interceptors>
> >   <interceptor name="interceptor1"
> >    class="com.abc.interceptors.MenuInterceptor">
> >   </interceptor>
> >   <interceptor-stack name="myStack">
> >    <interceptor-ref name="defaultStack">
> >     <param name="exception.logEnabled">true</param>
> >     <param name="exception.logLevel">ERROR</param>
> >    </interceptor-ref>
> >    <interceptor-ref name="interceptor1" />
> >   </interceptor-stack>
> >  </interceptors>
> >  <default-interceptor-ref name="myStack"></default-interceptor-ref>
> >
> > i.e I have a interceptor which I am calling after the defaultStack
> executes.
> >
> > My MenuInterceptor has the following code fragment in my intercept method
> > of MenuInterceptor
> >
> > ActionContext ac = actionInvocation.getInvocationContext();
> > String result = actionInvocation.invoke();
> >
> >  if( null==ac.getSession().get("menu")){
> >    menu = parser.getMenu();
> >    ac.getSession().put("menu", menu);
> >  }
> > LOG.debug("menu from session at end of intercept is:
> > "+ac.getSession().get("menu"));
> > return result;
> >
> > i.e after the action logic executes, I am checking if the sesssion has
> the
> > object. if the object is not present I am populating it and storing in
> the
> > session.
> > my LOG outputs valid object in the first launch also.
> >
> > When I execute for the first time, the menu object is not available in
> the
> > JSP, however if I refresh the page, the menu object is available in the
> JSP.
> > I could not have my custom interceptor to execute after the default
> > interceptors stack as the result already gets comitted and I cannot put
> > object in my session.
> > I suspect there is something done by some interceptor in the default
> stack
> > which I am missing.
> >
> > Could you please let me know how I can set something in session in
> > Interceptor and have it available in my JSP.
> >
> > Thanks,
> > JK
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

Reply via email to