01
Aug 10

Struts 2 enum form value

If you want to use enums in jsps while employing the struts 2 framework, add the following in your xwork-conversion.properties file:

java.lang.Enum = com.opensymphony.xwork2.util.EnumTypeConverter


01
Aug 10

Struts 2 test enum

In my Struts 2 app I needed to check for an enum value in the jsp. Using the struts <s:if test=”"> tag this can be done :

<s:if test=’#role.toString()!=”PAID”‘></s:if>

Hope this helps out someone. What I’m doing is getting the string representation of the enum and comparing the same. I did not know we could do a toString() here, hence thought of blogging about it!