Re: [S2] grabbing current URL in an interceptor

2008-10-20 Thread Tobin Juday
I'm not sure what you're asking for.  The code I posted is the code
that would live in the LoginInterceptor, along with any other code you
have for checking for a valid session.

Tobin


> Tobin-could you forward what the LoginInterceptor interface would look like?
>
> Thanks
> Martin

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



Re: [S2] grabbing current URL in an interceptor

2008-10-18 Thread Tobin Juday
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]



Re: Date in jspx

2008-10-16 Thread Tobin Juday
How about something like:



(disclaimer: haven't actually run it yet)

Tobin

On Thu, Oct 16, 2008 at 11:42 AM, Pablo Vázquez Blázquez <
[EMAIL PROTECTED]> wrote:

> Hi,
>
> I have a long representing a date. How can I get the date and time
> associated in a jspx?
>
> I tried:
>
> format.date.short={0, date, short}
> format.time.short={0, time, short}
>
> 
> 
>
> But it gives me "null null", for instance with value = 1224170724804
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Email validation

2008-10-12 Thread Tobin Juday
Hi all.  I noticed that the built-in Struts2 email validator is too strict
with characters it allowd.  In my case, it was preventing me from using
Gmail's trick with the plus sign.
(If I have the email address [EMAIL PROTECTED], I can add a plus sign and any
additional text, and it all gets "forwarded" to my example account. So,
[EMAIL PROTECTED] <[EMAIL PROTECTED]>,
[EMAIL PROTECTED]<[EMAIL PROTECTED]>
, [EMAIL PROTECTED] <[EMAIL PROTECTED]>, etc. all go to my
[EMAIL PROTECTED] account.)

Unfortunately, the email validator only allows letters, numbers, '.', '-',
 and '_'.  I went ahead and substituted a new regex in the  element
in my validator.xml, but I think we should expand the allowable characters
in the default pattern.

Here's a useful post I found regarding the issue:
http://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx

Thoughts?

Tobin