Two Laptop Bag*
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 Android Security Essentials Live Lessons this week in the Android 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.
I agree. Here's the link:
subject: Struts 2 - Saving value in map inside a map
Similar Threads
Requested Resource Not Found Error
javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" error?
Database to Hashmap
Bind a multple InputText values into HashMap<String,ArrayList<Integer>> in JSF
Struts2 Iterator Radio Tag Display Issue.