You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by HENRY Pierre <pi...@unine.ch> on 2009/05/05 16:30:54 UTC

Chaining actions specifying method name

Hi,

I am new to Struts2 but after struggling a couple of weeks with the doc (hard to find up-to-date doc for 2.1.6) and a couple out-of-date books, I am really starting to appreciate the simplicity and flexibility !

I am using Struts 2.1.6.

I have built a SecurityInterceptor, which checks authentication and permissions of the user, in particular if the invocated action is authorized, based on the action name. The action name is read using :

invocation.getProxy().getActionName();

I also tried 

invocation.getInvocationContext().getName();

In general, invocation.getProxy().getActionName() returns the name of the action, and as I use the action!method pattern in the URL I could also get the method from getMethodName(). Perfect.

But then I have a navigation menu action which chains to the selected action. The properties nextAction and nextNamespace are properties from the MenuSelectAction :

<action name="Menu" class="my.MenuSelectAction" >
   <result type="chain" name="success">
     <param name="actionName">${nextAction}</param>
     <param name="namespace">${nextNamespace}</param>
   </result>
</action> 

It works fine but there is no "methodName" parameter possible for the chain result, so I have to put the litteral "myAction!method" in the nextAction property. Then the right action with the right method is invocated, but in my interceptor the 

invocation.getProxy().getActionName() 

method returns "myAction!method" and the authorization check fails because it should be looking only for "myAction".

So we have two different behaviours, depending if the action was chained or invocated directly.

This is not so bad for me and I can easily find a work-around, but it might be worth it to add a "methodName" parameter to the chain type result, and then to invoke the action in the same manner than when it is invoked directly ?

Cheers and thanks for the good work !

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