One other option that I've used with great success is to create a
@LoginNotRequired annotation. Then, just checked for that annotation
in your interceptor. I have done it where you can put the annotation
on the class (which affects all action methods in the class) or just
on the method (which only affects that particular action method).
This is also nice because now your logic around whether or not users
can access certain pages are actually with the code for the action,
not in some interceptor method somewhere.
Some sample code:
Object action = invocation.getAction();
Class actionClass = action.getClass();
if (actionClass.isAnnotationPresent(LoginNotRequired.class)) {
// action class has @LoginNotRequired annotation, go ahead and let
the user through
return invocation.invoke();
}
else if
(actionClass.getMethod(invocation.getProxy().getMethod()).isAnnotationPresent(LoginNotRequired.class))
{
// method has @LoginNotRequired annotation, go ahead and let the user through
return invocation.invoke();
}
Of course, this assumes you're using Java 5.
Tobin
On Sat, Oct 18, 2008 at 4:18 AM, Nils-Helge Garli Hegvik
<[EMAIL PROTECTED]> wrote:
>
> The ActionProxy has methods for accessing the name, namespace and
> method of the action, and the ActionInvocation has a method for
> accessing the ActionProxy. The ActionInvocation also has a method for
> accessing the ActionContext, which in turn you can use to get the
> parameters.
>
> Nils-H
>
> On Sat, Oct 18, 2008 at 1:55 AM, Pierre Thibaudeau
> <[EMAIL PROTECTED]> wrote:
> > Thanks Nils. Though, to be honest, it doesn't really help since my previous
> > post in this thread (and the question it asks) was based on a reading of
> > those very links...
> > ;)
> >
> > I hit the same wall: how to extract from an ActionInvocation (or an
> > ActionContext) the namespace, the name and the parameters of the current
> > action (or, equivalently, the URI).
> >
> > 2008/10/17 Nils-Helge Garli Hegvik <[EMAIL PROTECTED]>
> >
> >> Maybe these links will help:
> >>
> >>
> >> http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/ActionInvocation.html
> >>
> >> http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/ActionProxy.html
> >>
> >
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]