Hi there,
I have a JavaBean that contains a java.util.Map data member with associated getter/setter.
I want to reference the value of the first key-value pair in the map using expression language.
I don't know/have access to the value's corresponding key in the map, so I can't just use something like:
<c:set var="myValue" value="${javaBean.map['firstEntryKey']}" />
...do something useful with myValue...
I just know that I want the first (only) value in the map.
All I've come up with is to iterate over the contents of the map, and determine if I've got the 'first' element, using LoopTagStatus.isFirst().
<c:forEach items="${javaBean.map}" var="mapEntry" varStatus="status">
<c:if test="${status.first}" >
<c:set var="myValue" value="${mapEntry.value}" />
...do something useful with myValue...
</c:if>
</c:forEach>
but that seems a bit clunky.
Am I missing something here? Is there a more elegant way to do this?
Thanks for your help.
Regards,
Ken.