That's what implementing a PreResultListener means; it's an interface, you
implement one.

I still think the whole PreResultListener thing is a bit opaque, I wrote up
something about that a couple of years ago--I need to dig that up.

Dave

On Wed, Nov 16, 2011 at 5:38 PM, Jyothrilinga Rao <jyoth...@gmail.com>wrote:

> if my action determines that what is present in session is no more valid,
> then it would clear this object from session. My interceptor has to check
> and set the correct object in session after action has returned.
>
> The setting in session has to happen after action invocation and before JSP
> rendering.
>
> Interceptor implementing PreResultListener did not work for me.
>
> I could get it working with the following snippet.
> invocation.addPreResultListener(new PreResultListener() {
> });
>
> Thank you,
> JK.
>
> On Wed, Nov 16, 2011 at 11:45 AM, Dave Newton <davelnew...@gmail.com>
> wrote:
>
> > 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