Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to compare Enums using Struts if tag?  RSS feed

 
Piyush Paramane
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!