I have a map userDetailsMap<String,List<String>> available in my jsp.
And eligibleUser,notEligibleUser,enrolledUser are the keys.
I can easily check for the key inside s:iterator tag.
Like(This code is working) :
<s:iterator var="userDetailsMap" value="context.userDetails">
<s:if test="%{#userDetailsMap.key=='eligibleUser'}">
//some code
</s:if>
<s:if test="%{#userDetailsMap.key=='notEligibleUser'}">
//some code
</s:if>
<s:if test="%{#userDetailsMap.key=='enrolledUser'}">
//some code
</s:if>
</s:iterator>
But how I check that a particular key is present or not?
I have used :
1.
<s:if test="%{#userDetailsMap['eligibleUser'] == null}">
//some code
</s:if>
2.
<s:if test="%{#userDetailsMap.containsKey('eligibleUser')}">
//some code
</s:if>
But both of them didn’t work.
Please suggest me.
EDIT: based on your statement that your iterator works,
this is working (tested):
If your userDetail is exposed through a getter directly by the Action, then use
I’m assuming that UserDetails is the bean containing the authenticated user’s “badge”, and the three List inside the map are the Use Cases grouped by their User Role.
In this case, to print all the Use Cases based on the User Role of the authenticated user, without even knowing the keys of the roles, use: