struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Benedetti <eric.benede...@sherwin.com>
Subject LazySortedMap of LazyList Objects in a Form
Date Fri, 17 Nov 2006 17:35:24 GMT
I've got a Form which contains a LazySortedMap, the keys being Strings 
and the values being LazyList objects.  Each LazyList object contains a 
list of Checkbox objects (basically just like LabelValueBean objects).  
In the jsp, I would like to iterate through the sorted map, and for each 
LazyList, iterate through that printing out the Checkbox values.  I 
cannot get this working !  Anyone know how I can write my jsp so that 
each checkbox value is something like group(keyname).checked[index] ?  
Help is much appreciated!

I've tried in the jsp something like:

     <nested:iterate id="group" property="groups">
        <bean:define name="group" property="key" id="thiskey" 
type="java.lang.String"/>
            <nested:iterate id="box" name="group" property="value" 
indexId="i">           
                <% String cbprop = "group(" + thiskey + ")[" + i + 
"].checked"; %>
                <html:checkbox property="<%= cbprop %>"/>
            </nested:iterate>           
     </nested:iterate>   

I've got the form defined:

    protected Map groups = MapUtils.lazySortedMap(
                                                        new TreeMap(), 
new Factory() {
                                                            public 
Object create() {
                                                                return 
buildGroup();
                                                            }
                                                        });


    public Map getGroups() {
        return groups;
    }

    public void setGroups(final TreeMap newGroups) {
        groups = MapUtils.lazySortedMap(newGroups, new Factory() {
            public Object create() {
                return buildGroup();
            }
        });
    }   

    private List buildGroup() {
        List checkboxes = ListUtils.lazyList(new java.util.ArrayList(), 
new Factory() {
            public Object create() {
                return new Checkbox();
            }
        });
       
        return checkboxes;
    }  

    public void setGroup(String key, Object value) {
        getGroups().put(key,value);
    }
    public Object getGroup(String key) {
        return getGroups().get(key);
    } 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message