Hi everyone,
I have hashmap that was created on a page using the struts2 <s:set> tag. It looks something like this
<s:set var="mymap" value="#request.mymap"/>
At some point in the page, i need to get a value from the hashmap based upon a key, and i want to do it using OGNL.
The key is generated based upon some logic, which i store using another <s:set> tag. Something like this
<s:set var="mykey" value="1">
I need to get a value from the hashmap using this key. And i need to display it.
How do i simply call the get function on the hashmap?
I tried this <s:property value="#mymap[#mykey]"/>
and this <s:property value="#mymap[%{#mykey}]"/>
and this <s:property value="%{#mymap[%{#mykey}}]"/>
The third one obviously does not work because of the nesting problem. But the same nesting logic is applicable to the second case as well, due to the manner the value attribute is handled. However none seem to work for me.
The issue here is that my key is unknown. It is a dynamically generated string based upon some pattern. I need to access the object stored in the hashmap using this dynamic key. And due to the inability of nesting ognl, i am in a fix.
I suppose the issue is very simple. I almost feel that i get it, but somehow the solution eludes me. Could someone please tell me what i am missing here?