File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
 
Similar Threads
TreeMap
<s:submit> problem
Iterating a hashmap in jsp using struts2
.get()
about hashmap implementation of arraylist