john cely

Greenhorn
+ Follow
since May 24, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by john cely

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.
10 years ago