Hi Peter,

On Thu, Apr 10, 2008 at 12:08 PM, Peter Theissen <[EMAIL PROTECTED]> wrote:
<snip />
>  I have the "SimpleInterceptor":
>  >>>
>  public String intercept(ActionInvocation invocation) throws Exception {
>   System.out.println("The action is being intercepted!");
>   return invocation.invoke();        //return Action.SUCCESS; (**)
>  }
>  <<<

You 'usually' don't return anything else from the intercept method
despite the return code of the action invocation itself. Anyway the
return of your interceptor leads back to the action invocation, which
then puts the resulting success-String into a local variable and
returns null. End of processing. So neither action nor result are
executed, as there never is a call to actionInvocation.invoke() at the
end of your interceptor stack, which whould do this. You only
understand what a recursion is, when you've understood recursion ;-)

>  and the struts.xml contains:
>  >>>
>  <action name="listRegistrationsWaiting" class="registrationWaitingAction"
> method="execute">
>   <result>pages/list.jsp</result>
>   <result name="input">pages/list.jsp</result>
>   <interceptor-ref name="simpleInterceptor"/>           </action>
>  <<<

You know this leaves you with only ONE interceptor on your interceptor
stack, the default stack is completely omitted! Means no configuration
parameters or URL parameters injected into your action, and lots of
other stuff you miss. Try something like

<action name="foo" class="org.bar.Foo">
  <result>/foo.jsp</result>
  <interceptor-ref name="defaultStack" />
  <interceptor-ref name="simpleInterceptor" />
</action>

>  When I comment in (**) instead of the return,
>  the result is not displayed (list.jsp) is not invoked.
>  I dont understand why, since the interceptor should
>  be called as the LAST step as far as I understand the
>  doc?! Therefore, there should be no influence of
>  the interceptor at the result at all!

Nope. actionInvocation.invoke() calls the next intercepter on the
interceptor stack until there are no more interceptors. THEN the call
to actionInvocation.invoke() from the last interceptor on the stack
invokes the action. Thus in your example above the action never should
be called.

>  But obvously, Im misunderstanding something, since I found
>  out that it works, when I just call return invocation.invoke();
>  But also in this case I wounder why the interceptor is called
>  BEFORE the DB Access (I can see that on the console),
>  since the interceptor is provided as the LAST part of the
>  action.

Check out some more docs in the wiki, especially take a look at the
big picture[1] and interceptors[2].

Cheers,
-Ralf


[1] http://struts.apache.org/2.0.11.1/docs/big-picture.html
[2] http://struts.apache.org/2.x/docs/interceptors.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to