When trying to get an EL condition working I found that enum values are completely ignored. This seems to me contrary to the spec.
<c:out value='${com.foobar.data.BookingStatus.FAILED}' />
<c:out value='${BookingStatus.FAILED}' />
<c:out value='${com.foobar.data.BookingStatus.failed}' />
<c:out value='${BookingStatus.failed}' />
<c:if test="${empty BookingStatus.FAILED }">empty</c:if>
To my surprise these all evaluate to empty. Why is the Enum class not recognized? This is happening in a current stable Tomcat instance.
Can this be a classpath issue? The Enum is used successfully in controller code but nowhere else in JSPs. It is supplied in a jar in the lib directory of the deployment.
UPDATE:
My intention is to compare a supplied Integer to an Enum's property like this:
<c:when test='${bookingInformation.bookingStatus eq BookingStatus.FAILED.code}'>
FOOBARFAIL
</c:when>
Unfortunately the value being checked can't be changed and will remain an Integer. The Enum looks as follow (simplified):
public enum BookingStatus {
COMPLETED(0), FAILED(1);
private final int code;
private BookingStatus(int code) {
this.code = code;
}
public int getCode() {
return code;
}
}
I want to avoid to hard code the Integer value of FAIL etc. and use the enum instead for the comparison.