I second the Spring Security stuff, it's great.


-----Original Message-----
From: Wes Wannemacher [mailto:w...@wantii.com] 
Sent: Wednesday, April 15, 2009 4:09 PM
To: Struts Users Mailing List
Subject: Re: Struts2 equivalent of <logic:present role=""...>

On Wednesday 15 April 2009 16:00:34 Russell Neufeld wrote:
> Hi all,
>
>     We're porting an app from Struts 1 to Struts 2, and I'm having
> trouble figuring out how to conditionally include a portion of a JSP
> depending on the role of the user principal.  In Struts 1 we did this:
>
> <logic:present role="SERVICE,SYSTEM">
>     ... some html ...
> </logic:present>
>
>     What's the preferred way of doing this in Struts2?  Thanks,
>
>        Russ

There are a couple of ways to do it, personally, I would use Spring Security

and incorporate their tag library. It will eliminate quite a bit of work on 
your part.

Since you are probably pressed for time since this is an upgrade effort, the

better method would be to expose your user object in a way that you can get
at 
the list of roles (such as putting it in the session). Then, just use s:if
and 
some OGNL to check like this - 

<s:if test="#session.user.roles.contains('REQUIRED_ROLE')">
...
</s:if>

-Wes

-- 

Wes Wannemacher
Author - Struts 2 In Practice 
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher


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


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

Reply via email to