Sigh....that kind of breaks the whole purpose of using JSTL. I am forced to jump through several silly loops to make the conditional work in JSTL, and even then I can't get completely rid of scriptlets. The whole thing would be so simple to do if I gave up JSTL. I have to say I am quite surprised (and annoyed) about this - how can JSTL be touted as a valid replacement (and "progress") for standard scriptlets if it fails in such a simple and common thing? I have to _learn a new language_ to use JSTL, and this is all I get? :(

Anyway, enough rant, thanks for the info.


From: Paul McCulloch <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: 'Struts Users Mailing List' <[EMAIL PROTECTED]>
Subject: RE: [OT(?)] Comparing against a typesafe enum in JSTL
Date: Thu, 26 Aug 2004 13:54:27 +0100

I've asked this before on the list and didn't get a neat answer. I've
resorted to using c:set & scriptlets to extract the value from the static
and store it in a scoped attribute for use with JSTL.

Paul


> -----Original Message----- > From: Janne Mattila [mailto:[EMAIL PROTECTED] > Sent: Thursday, August 26, 2004 1:42 PM > To: [EMAIL PROTECTED] > Subject: Re: [OT(?)] Comparing against a typesafe enum in JSTL > > > Um, no, doesn't work: > > [ServletException in:/pages/cd/content/common/menu.jsp] > jsp.error.tlv.invalid.page > > 10: tag = 'when' / attribute = 'test': An error occurred > while parsing > custom action attribute "test" with value > "${sessionScope.role.roleChar.equals(cd.business.Role.ADMIN)}" > : Encountered > "(", expected one of ["}", ".", ">", "gt", "<", "lt", "==", > "eq", "<=", > "le", ">=", "ge", "!=", "ne", "[", "+", "-", "*", "/", "div", > "%", "mod", > "and", "&&", "or", "||"] > > besides, wouldn't that be comparing a char (besides, calling > char's equals() > method, which does not exist sice char is a primitive) to a Role? > > Anyway, thanks for the suggestion, other ideas? > > > >From: Can Zheng <[EMAIL PROTECTED]> > >Reply-To: Can Zheng <[EMAIL PROTECTED]> > >To: Struts Users Mailing List <[EMAIL PROTECTED]> > >Subject: Re: [OT(?)] Comparing against a typesafe enum in JSTL > >Date: Thu, 26 Aug 2004 20:32:27 +0800 > > > >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] > > > > _________________________________________________________________ > Help STOP SPAM with the new MSN 8 and get 2 months FREE* > http://join.msn.com/?page=features/junkmail > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] >


**********************************************************************
Axios Email Confidentiality Footer
Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message, and notify us immediately. If you or your employer does not consent to Internet email messages of this kind, please advise us immediately. Opinions, conclusions and other information expressed in this message are not given or endorsed by my Company or employer unless otherwise indicated by an authorised representative independent of this message.
WARNING:
While Axios Systems Ltd takes steps to prevent computer viruses from being transmitted via electronic mail attachments we cannot guarantee that attachments do not contain computer virus code. You are therefore strongly advised to undertake anti virus checks prior to accessing the attachment to this electronic mail. Axios Systems Ltd grants no warranties regarding performance use or quality of any attachment and undertakes no liability for loss or damage howsoever caused.
**********************************************************************



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


_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail



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



Reply via email to