You're right - the <s:if> method may be a quicker change. I'll give that a shot. Thanks for the quick answer.

   Russ

Wes Wannemacher wrote:
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


Reply via email to