Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get Key from Map at particular index using OGNL

 
kiran chirravuru
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to get Key at particular index using OGNL in struts2
 
Ruth Mills
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic