Hi,
you can use 

<c:when test="${sessionScope.role.roleChar.equals(cd.business.Role.ADMIN)}">
...




On Thu, 26 Aug 2004 12:09:56 +0000, Janne Mattila
<[EMAIL PROTECTED]> wrote:
> First, apologies for a slightly OT question; this is more about JSTL and
> less about Struts.
> 
> Let's say I have a "Role" object in session. It is a typesafe enum, with
> values Role.ADMIN and Role.USER. How can I compare the object in session
> against those values, using JSTL? I can't figure out how to refer to
> typesafe enum objects using the JSTL notation. And I don't really want to
> change the enum class into a JavaBean.
> 
> Role:
> 
> public class Role {
>        private char roleChar;
> 
>        public static final Role USER = new Role('u');
>        public static final Role ADMIN = new Role('a');
> 
>        private Role(char roleChar) {
>                this.roleChar = roleChar;
>        }
> 
>        char getRoleChar() {
>                return roleChar;
>        }
> 
>        public boolean equals(Object obj) {
>                Role r2 = (Role) obj;
>                if (r2 == null) {
>                        return false;
>                }
>                return r2.getRoleChar() == roleChar;
>        }
> }
> 
> My attempt to use it in JSP page:
> 
> <c:choose>
> <c:when test="${sessionScope.role == cd.business.Role.ADMIN}">
>  Hello Admin
> </c:when>
> <c:otherwise>
>  Hello User
> </c:otherwise>
> </c:choose>
> 
> does not work.
> 
> (this special case could possibly be handled using container managed
> authorization and it's roles etc....but it's not really the point here)
> 
> _________________________________________________________________
> MSN 8 with e-mail virus protection service: 2 months FREE*
> http://join.msn.com/?page=features/virus
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
Best regards,

Can Zheng

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

Reply via email to