You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Borislav Iordanov <bo...@speakeasy.net> on 2002/04/15 07:25:59 UTC
[JSTL] Java enum constants
Hi,
It would be useful if the JSTL expression language supported enum
constants access through the '.' operator. For example:
class A
{
public final static int ENUM_1 = 0;
public final static int ENUM_2 = 1;
public int getType() // returns one of ENUM_1, ENUM_2 etc...
}
and then
<c:choose>
<c:when test="${a.type == a.ENUM_1}">
do something
</c:when>
<c:when test="${a.type == a.ENUM_2}">
do something else
</c:when>
</c:choose>
Could it be done?
Thanks,
Boris
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [JSTL] Java enum constants
Posted by Borislav Iordanov <bo...@speakeasy.net>.
Hi,
I think accessing the static values of the class of the actual object
would be fine (well-defined, clear, intuitive). But I agree it departs
from the "objects with properties" model.
In any case, a mechanism for defining (and/or accessing) named constants
would be nice.
Thanks for the quick response!
Regards,
Boris
Shawn Bayern wrote:
>Yeah, the topic has come up. It could be done in principle, but
>
> - it won't make it into JSTL 1.0
>
> - there are problems with referring to static members of a class
> The JSTL EL just refers to objects, so it's not clear which class in
> the object's ancestry hierarchy the static values would come from.
> We'd probably need to add a mechanism to refer to a class specifically,
> and this would complicate a language that's intended to hide the
> details of Java data types for page authors.
>
>Hope that helps,
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [JSTL] Java enum constants
Posted by Shawn Bayern <ba...@essentially.net>.
Yeah, the topic has come up. It could be done in principle, but
- it won't make it into JSTL 1.0
- there are problems with referring to static members of a class
The JSTL EL just refers to objects, so it's not clear which class in
the object's ancestry hierarchy the static values would come from.
We'd probably need to add a mechanism to refer to a class specifically,
and this would complicate a language that's intended to hide the
details of Java data types for page authors.
Hope that helps,
--
Shawn Bayern
Author, "JSP Standard Tag Library" http://www.jstlbook.com
(coming this summer from Manning Publications)
On Mon, 15 Apr 2002, Borislav Iordanov wrote:
> Hi,
>
> It would be useful if the JSTL expression language supported enum
> constants access through the '.' operator. For example:
>
> class A
> {
> public final static int ENUM_1 = 0;
> public final static int ENUM_2 = 1;
>
> public int getType() // returns one of ENUM_1, ENUM_2 etc...
> }
>
>
> and then
>
> <c:choose>
> <c:when test="${a.type == a.ENUM_1}">
> do something
> </c:when>
> <c:when test="${a.type == a.ENUM_2}">
> do something else
> </c:when>
> </c:choose>
>
> Could it be done?
> Thanks,
> Boris
>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>