tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pid <...@pidster.com>
Subject Re: Inconsistent output of Java 5 enums
Date Fri, 15 Oct 2010 15:11:46 GMT
On 15/10/2010 15:22, Christopher Schultz wrote:
> Oliver,
>=20
> On 10/15/2010 10:19 AM, Oliver Siegmar wrote:
>> Chris,
>=20
>> On Friday 15 October 2010 16:11:29 Christopher Schultz wrote:
>>>> not. Sorry for the confusion. So this is a simplified example for my=
 enum:
>>> You're right: that was stupid of me. I had forgotten your toString me=
thod.
>>>
>>> Uh... why override the toString method like that?
>=20
>> Well, as written in java.lang.Enum:
>=20
>> An enum type should override this method when a more "programmer-frien=
dly"=20
>> string form exists.
>=20
> Fair enough. I feel like VALID versus INVALID (which could be confusing=

> in this case) would be plenty programmer-friendly.
>=20
>>>> The thing is, that EL is using the name() method to print the enum a=
nd
>>>> JSTL is using toString(). I did not expect a different enum treatmen=
t
>>>> here.
>>>
>>> If you need it to emit the same thing, doing:
>>>
>>> <c:out value=3D"${myEnumValue.name}"/>
>=20
>> No, because that would call a method getName() which doesn't exist - t=
he=20
>> method is named name().
>=20
> <c:out value=3D"${myEnumValue.getName()}"/>

I don't think that'll work in 6.0.

> Or, just consistently use EL, since that actually works as you expect.

+1  '<c:out' seems surplus.


p

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



Mime
View raw message