This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread 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 Building Microservices this week in the Design 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
 
Have you checked out Aspose?
 
subject: Get Key from Map at particular index using OGNL
 
It's not a secret anymore!