Hi Rick,

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")

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. 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>


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>




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.





--
Jason Lea


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to