• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 - Saving value in map inside a map

 
john cely
Greenhorn
Posts: 1
  • 0
  • 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) {
      this.map = map;
}

public Map<String, Map<Integer, MyEntity>> getMap() {
      return this.map;
}

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">
      <tr>
            <td>${status.index}</td>
            <td>${key}</td>
            <s:iterator value="integersList" id="myInteger">
                  <td>
                        <s:textfield name="map[${key}][${myInteger}].myEntityAttribute" value="%{map[#attr.key][#attr.myInteger].myEntityAttribute}" id="attr_${key}_${myInteger}" theme="simple" size="10" />
                  </td>
            </s:iterator>
      </tr>
</s:iterator>

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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic