Win a copy of Penetration Testing Basics this week in the Security forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 - Saving value in map inside a map

john cely
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i'm currently working with Struts 2 and i have this situation:

In my Action class:

private Map<String, Map<Integer, MyEntity>> map;

public void setMap(Map<String, Map<Integer, MyEntity>> map) { = map;

public Map<String, Map<Integer, MyEntity>> getMap() {

In my JSP, I use an iterator to go through the map using the 'key' variable, then iterate over another list (of integers) and use this integer to go through the second map, like this: map[${key}][${myInteger}]

<s:iterator value="map" status="status">
            <s:iterator value="integersList" id="myInteger">
                        <s:textfield name="map[${key}][${myInteger}].myEntityAttribute" value="%{map[#attr.key][#attr.myInteger].myEntityAttribute}" id="attr_${key}_${myInteger}" theme="simple" size="10" />

Doing this for getting the value works fine: value="%{map[#attr.key][#attr.myInteger].myEntityAttribute}"

But when I want to save the changes I can not make it work: name="map[${key}][${myInteger}].myEntityAttribute"

I don't know what I am doing wrong, or if this can not be done (I'm pretty sure there must be a way), but I'm kind of tired of trying.

I would appreciate any suggestions, really, anything that can help is welcomed.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic