Hi all, The best thing to do to use the isUserInRole method is to define a filter which propagate your own request wrapper ... in this wrapper you redefine the isUserInRoleMethod .... It's this method which will be used by the struts2 role interceptor.
To define a taglib which can test the role, the simpliest way is to extends the if tag ... you add a new attribute : roles ... in the populate method, you call the setTest method with the result of wheter the user have the role or not ... at the end of the populateParams method, you call the super.populateParams method ... here's the code : import javax.servlet.http.HttpServletRequest; import org.apache.struts2.views.jsp.IfTag; public class IsUserInRoleTag extends IfTag { private String roles; @Override protected void populateParams() { setTest("" + condition()); super.populateParams(); } private boolean condition() { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); String[] rolesArray = roles.split(","); boolean result = false; for (int i = 0; i < rolesArray.length && !result; i++) { result = request.isUserInRole(rolesArray[i]); } return result; } /* GETTER AND SETTER */ public void setRoles(String roles) { this.roles = roles; } } Hope this helps ! Tcho -- Romain Le 16 nov. 07 à 14:28, Gabriel Belingueres a écrit : I personally tried with struts tags and JSTL tags I decided to give up after a while (I solved it by creating my own isUserInRole tag.) This in fact would be a nice addition to the struts 2 tags, it even can be implemented by delegating to the if tag implementation, so that you can have automatic <s:else> compatibility. :) 2007/11/16, Filippov, Andrey <[EMAIL PROTECTED]>: Hello Everybody! I need to check roles of a user in my app to decide whether to render some elements on JSP or not. Does someone happen to know how could I do it (I mean the syntax of <s:if tag together with request.isUserInRole("role") on the JSP page)? Thanks a lot. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]