struts2: enum in IF
el, java, ognl, struts2
Solution
Use `toString` method to compare `enums`.
<s:if test="ENUM.toString() == 'some_enum_as_string'">
And if you want to use `enums` in JSP
<s:if test="@package.ENUM@enumvalue.toString() == 'some_enum_as_string'">
Problem
How does the following Java condition translate into `s:if test="..."` in struts2? ``` if(company.getAffiliateId().asInt() != com.foo.bar.Affiliates.XYZ.asInt()){ // do something } ``` company.getAffiliateId() returns `BigDecimal` com.foo.bar.Affiliates is an `enum` This doesn't work: ``` <s:if test="%{company.affiliateId.asInt() != com.foo.bar.Affiliates.XYZ.asInt() }"> alert("do something"); </s:if> ```