Don't you mean "address[index](street)" instead of "address[index]{street}" (parens instead of braces)?
> -----Original Message----- > From: Mathias, Merlyn [mailto:[EMAIL PROTECTED] > Sent: Tuesday, February 25, 2003 11:02 AM > To: 'Struts Users Mailing List' > Subject: RE: Maps and Nested Properties problems > > > Hi David and Rand, > > Thank you very much for your help. I fixed my problem by referring to the > property name by address[index]{street} instead of address[index].street. > It > worked. > > Thanks Again, > Merlyn. > > -----Original Message----- > From: WILLIAMS,RAND (HP-USA,ex1) [mailto:[EMAIL PROTECTED] > Sent: Tuesday, February 25, 2003 1:40 PM > To: 'Struts Users Mailing List' > Subject: RE: Maps and Nested Properties problems > > Hello Merlyn, > > I am having trouble with modifying the Map.Entry.value, but this might > help > you: > > From the docs > http://jakarta.apache.org/struts/userGuide/struts-logic.html#iterate > > [ Normally, each object exposed by the iterate tag is an element of the > underlying collection you are iterating over. However, if you iterate over > a > Map, the exposed object is of type Map.Entry that has two properties: > > key - The key under which this item is stored in the underlying Map. > value - The value that corresponds to this key. > So, if you wish to iterate over the values of a Hashtable, you would > implement code like the following: > > <logic:iterate id="element" name="myhashtable"> > Next element is <bean:write name="element" property="value"/> > </logic:iterate> ] > > I have used this: > > [hmtest.jsp] > (note that type="..Entry" is reslly implicit - I did it for the sake of > the > <%=..%> chunk) > > <logic:notEmpty name="_engineerHM" property="products" > > <logic:iterate name="_engineerHM" property="products" id="product" > type="java.util.Map.Entry" > > <html:text name="product" property="key" /> > <html:text name="product" property="value" /> > <html:multibox name="_engineerHM" property="products_selected" > value='<%=(String)roduct.getKey()%>' /> <br> > </logic:iterate> > </logic:notEmpty> > > [struts-config.xml] > <form-bean > name="_engineerHM" > type="org.apache.struts.action.DynaActionForm"> > <!-- want to test iteration on a HashMap --> > <form-property > name="products" > type="java.util.HashMap" /> > <form-property > name="products_selected" > type="java.lang.String[]" /> > </form-bean> > > [DynaActionFormHashMapTest.java] > (you will need to make a new hash map if one doesn't exist, > this would be in the ActionForm reset() if I wasn't using DynaActionForm) > if ( pHM == null ) { > log.info(" creating new HashMap for products"); > pHM = new HashMap(); > } > > -----Original Message----- > From: Mathias, Merlyn [mailto:[EMAIL PROTECTED] > Sent: Tuesday, February 25, 2003 12:57 PM > To: '[EMAIL PROTECTED]' > Subject: Maps and Nested Properties problems > > > Hi, > > I would like to know how to use a Map with nested properties. I have an > ArrayList of Maps in my ActionForm. I want to do something like this in my > JSP page. > > <logic:iterate id="address" name="addressList" indexId="index"> > > Street: <html:text property="address[index].street" /> > City : <html:text property=" address[index].city" /> > > > And so on ....................... > > </logic:iterate> > > public class MyActionForm extends ActionForm > { > private ArrayList addressList; > > public MyActionForm() > { > addressList = new ArrayList; > addressList.add(new HashMap()); > } > > public Object getAddress(int index) > { > return addressList.get(index); > } > > public void setAddress(int index, Object value) > { > addressList.set(index,value); > } > > > } > > I don't get any errors but the input values are not getting saved. The > ActionForm is in session scope. > > I know this works if I have an ArrayList of 'Address' beans with getters > and > setters. Is there any way to do this with Map? > > Thanks a lot, > Merlyn. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]