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>
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="@[email protected]() == 'some_enum_as_string'">
Got it, this works for me:
<s:if test="%{company.affiliateId != @[email protected]() }">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With