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]

