This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes Get  Key from Map at particular index using OGNL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Get  Key from Map at particular index using OGNL " Watch "Get  Key from Map at particular index using OGNL " New topic
Author

Get Key from Map at particular index using OGNL

kiran chirravuru
Greenhorn

Joined: Nov 25, 2009
Posts: 26
How to get Key at particular index using OGNL in struts2
Ruth Mills
Greenhorn

Joined: Apr 30, 2011
Posts: 1
This works for me, e.g. if I have a Map called "myMap" and want to get the key at index 0 from the map, then I can do something like this...

<s:hidden name="whatever" value="%{myMap.keySet().toArray()[0]}"/>

So in the OGNL, I have to call keySet() and then toArray() and can then just use an index in square brackets after that.

Hope that works for you too
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Get Key from Map at particular index using OGNL