This content has been marked as final.
Show 2 replies
-
1. Re: Accessing Enum with EL
pmuir Jan 3, 2008 5:41 PM (in response to menashe)EL doesn't support accessing enums like that. You would need to write an EL function I think.
-
2. Re: Accessing Enum with EL
menashe Jan 3, 2008 5:55 PM (in response to menashe)that is what i do now but this is not very efficient since it had to create enum object from string all the time (i can add each enum constant to the named class but it can be tedious when there are lots of enums)
public boolean isGood(final String value) { return status.equals(value); }
and this has to be added to each enum class (with Status.class updated to reflect the actuall class)public boolean equals(final String value) { if (value == null || value.length() == 0) { return false; } try { if (this == Enum.valueOf(Status.class, value)){ return true; } } catch (final IllegalArgumentException iae) { return false; } return false; }