On Sat, 2003-06-28 at 19:00, Jason Lea wrote: > Here are some ideas, I haven't tested them so they could be horribly > wrong :) > > The html-el:text tag are just like the html:text tag, but I can evaluate > EL expressions. > > What you want to generate is something like this: > > someCode: <input type="text" name="fooMap['aCode'].someCode" > value="aCode"><br> > > because when this is submitted Struts will do something like: > formBean.getFooMap().get("aCode").setSomeCode("a new value")
Thanks Jason. I'll have to try some of this. The problem with the above though is what do i substitute in for "aCode" that represents "key". The keys can be different obviously as the iterations take place. > > So then looking at the html:text tag documentation we see for 'property': > > "Name of this input field, and the name of the corresponding bean > property if value is not specified. The corresponding bean property (if > any) must be of type String." > > This means the value of 'property' will be the name of the text input > field - this is the bit we want to become name="fooMap['aCode'].someCode". > > The other importent part is the 'indexed' property: > > "Valid only inside of logic:iterate tag. Actually this seemed to also work within the JSTL foreach loop. > If true then name of the html > tag will be rendered as "id[34].propertyName". Number in brackets will > be generated for every iteration and taken from ancestor logic:iterate tag." > > You are using JSTL and have not created a logic:iterate tag so the index > isn't going to be generated for you. You could switch to using > logic:iterate and I think the tags figure out what to call themselves eg > > <html:form action="...."> > <logic:iterate id="beanInMap" name="fooMap"> > someCode: <html-el:text name="beanInMap" > property="deptCode" indexed="true"/><br> > </logic:iterate> > </html:form> I tried the above but it complained that it couldn't find my map (fooMap in the above example). > > or use the <nested:*> tags, which would be something like: > > <nested:form action="...."> > <nested:iterate name="fooMap"> > someCode: <nested:text property="deptCode" /><br> > </nested:iterate> > </html-el:form> > > If you want to use JSTL, you probably have to generate the property name > yourself: > > <html:form action="...."> > <c:forEach var="beanInMap" items="${formBean.fooMap}"> > someCode: <html-el:text > property="fooMap['${beanInMap.someCode}'].someCode" /><br> > someDescrip: <html-el:text > property="fooMap['${beanInMap.someDescrip}'].someDescrip" /><br> > <br> > </c:forEach> > </html:form> With the above I end up with the error: org.apache.jasper.JasperException: An error occurred while evaluating custom action attribute "property" with value "departments['${beanInMap.deptCode}'].deptCode": Unable to find a value for "deptCode" in object of class "java.util.HashMap$Entry" using operator "." (null) the syntax looks like: <c:forEach var="beanInMap" items="${employeeForm.departments}"> Code: <html:text property="departments['${beanInMap.deptCode}'].deptCode" /> <br> Name: <html:text property="departments['${beanInMap.deptName}'].deptName" /> <br> <br> </c:forEach> I've tried all kinds of other combos also and still stumped. Thanks for the help so far. > > Rick Reumann wrote: > > Ok this has me stumped... > > > > the down and dirty: > > > > formBean has HashMap called fooMap > > > > fooMap has keys that bring back beans of type BarBean > > > > BarBean has properties someCode , someDescrip > > > > Now I want to iterate over this map and create the properties based on > > the properties in BarBean and be able to update this form which will > > then update the underlying BarBeans in the map. > > > > (Ignore the part that I know that's a hassle about the reset method and > > making sure Map exist there). > > > > > > <c:forEach var="beanInMap" items="${formBean.fooMap}"> > > > > someCode: <html-el:text property="????????"/><br> > > someDescrip: <html-el:text property="????????"/><br> > > <br> > > > > </c:forEach> > > > > > > the text will display fine in the form with: > > > > someCode: <html-el:text name=beanInMap" property="beanInMap.deptCode" /> > > > > but when the form submits all the bean property values are null ( in the > > reset if it matters for testing i'm just creating a few maps with empty > > BarBeans in the map). > > > > I'm stumped.. any help much appreciated. > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]