tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Inconsistent output of Java 5 enums
Date Fri, 15 Oct 2010 14:22:43 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Oliver,

On 10/15/2010 10:19 AM, Oliver Siegmar wrote:
> Chris,
> 
> 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 method.
>>
>> Uh... why override the toString method like that?
> 
> Well, as written in java.lang.Enum:
> 
> An enum type should override this method when a more "programmer-friendly" 
> string form exists.

Fair enough. I feel like VALID versus INVALID (which could be confusing
in this case) would be plenty programmer-friendly.

>>> The thing is, that EL is using the name() method to print the enum and
>>> JSTL is using toString(). I did not expect a different enum treatment
>>> here.
>>
>> If you need it to emit the same thing, doing:
>>
>> <c:out value="${myEnumValue.name}"/>
> 
> No, because that would call a method getName() which doesn't exist - the 
> method is named name().

<c:out value="${myEnumValue.getName()}"/>

?

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

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAky4Y7MACgkQ9CaO5/Lv0PAeewCdGjswzmpXGShPgpLnYtt74CDv
Y04AoJkjy6pgZyXQuvMsA5SFv9HpAQaH
=pZSv
-----END PGP SIGNATURE-----

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


Mime
View raw message