aspose file tools*
The moose likes Struts and the fly likes How to compare Enums using Struts if tag? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to compare Enums using Struts if tag?" Watch "How to compare Enums using Struts if tag?" New topic
Author

How to compare Enums using Struts if tag?

Piyush Paramane
Greenhorn

Joined: Jul 17, 2012
Posts: 5
Hi,

I have an Enum in my bean, public enum Gender {male,female,unknown};
I am getting already selected enum value from previous JSP, now i want to compare it in my JSP and write some logic using struts tags.

e.g.
<s:if test="%{session.myBean.myGender == session.myBean.Gender.male}>
//Write some login when selected enum is male </s:if>
<s:if test="%{session.myBean.myGender == session.myBean.Gender.female}>
//Write some login when selected enum is female </s:if>
<s:else></s:else>

is it the correct way? i am not able to get selected enum value and it always enters in else part.
What would be the solution for this?
 
wood burning stoves
 
subject: How to compare Enums using Struts if tag?