• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to compare Enums using Struts if tag?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic