File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts 2 - Saving value in map inside a map Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 - Saving value in map inside a map" Watch "Struts 2 - Saving value in map inside a map" New topic

Struts 2 - Saving value in map inside a map

john cely

Joined: May 24, 2013
Posts: 1
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.
jQuery in Action, 3rd edition
subject: Struts 2 - Saving value in map inside a map
It's not a secret anymore!