Question

I have an enum:

enum DestinationTab{
        Overview,
        ThingsTodo
    };

I set an enumSet in my action class based on certain conditions. On my jsp, I'd like to render only those sections which are present in this enumSet.

This construct doesn't work:

   <s:if test="eSet.contains('ThingsTodo')">
    print something
   </s:if>

How can I use enumSet.contains(..) in jsp ?

Était-ce utile?

La solution

An EnumSet contains Enumeration members, not strings.

To get an enumeration member, you can use valueOf :

<s:if test="eSet.contains(DestinationTab.valueOf('ThingsTodo'))">
 print something
</s:if>

Or, when the specific member to use is hardcoded :

<s:if test="eSet.contains(DestinationTab.ThingsTodo)">
 print something
</s:if>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top