Monday, August 18, 2014

Accessing HashMap with JSTL


Hi All,


I have a HashMap returned from the server. There are two conditions

1. HashMap returned with only one set of key value pair or

2. HashMap with multiple set of data key value pairs.


Now in UI I have to display either text box or drop down box depending upon the size of map for that I am using length method



Java Code:



<c:choose>
<c:when test="${fn:length(myDto.mayMapInDto) eq 1}">
display text box
</c:when>
<c:otherwise>
display drop box
</c:otherwise>
</c:choose>

I can display drop box by looping but not sure how I can get only one element for text box. Tricky is I can't use key value to access since UI don't know what key will be returned.

No comments:

Post a Comment