T
Tim B
Can anyone point me to an example of using Struts indexed properties in a
situation with a formbean contaning a list of objects, each containing a
further list of objects, or point out if there is an error in the code
below? I would like to be able to round-trip to the server with full
repopulation without having to resort to doing what I did for textbox 4.
I have the following code in a jsp
<logic:iterate id="bean" name="myFormBeanName"
property="beanList" type="mypackage2.OuterBean"
scope="request" indexId="ind">
<%-- these 2 textboxes repopulate correctly --%
<html:text name="bean" property="label" indexed="true" />
<html:text name="bean" property="value" indexed="true"/>
<logic:iterate id="nestedBean" name="bean" property="nestedBeanList"
type="mypackage2.NestedBean" indexId = "ind2" >
<%-- textbox 3- this textbox repopulates correctly --%>
<input type="text"
name="bean[<%=ind.intValue()%>].nestedBean[<%=ind2.intValue()%>].beanValue"
value="<%=nestedBean.getBeanValue()%>"/>
<%-- textbox 3- this textbox does not repopulate correctly --%>
<html:text name="nestedBean" property="beanValue" indexed="true"/>
</logic:iterate>
</logic:iterate>
the html generated for textbox 3 is :
<input type="text" name="bean[0].nestedBean[0].beanValue" value="foo"/>
the html generated for textbox 4 is:
<input type="text" name="nestedBean[0].beanValue" value="foo">
situation with a formbean contaning a list of objects, each containing a
further list of objects, or point out if there is an error in the code
below? I would like to be able to round-trip to the server with full
repopulation without having to resort to doing what I did for textbox 4.
I have the following code in a jsp
<logic:iterate id="bean" name="myFormBeanName"
property="beanList" type="mypackage2.OuterBean"
scope="request" indexId="ind">
<%-- these 2 textboxes repopulate correctly --%
<html:text name="bean" property="label" indexed="true" />
<html:text name="bean" property="value" indexed="true"/>
<logic:iterate id="nestedBean" name="bean" property="nestedBeanList"
type="mypackage2.NestedBean" indexId = "ind2" >
<%-- textbox 3- this textbox repopulates correctly --%>
<input type="text"
name="bean[<%=ind.intValue()%>].nestedBean[<%=ind2.intValue()%>].beanValue"
value="<%=nestedBean.getBeanValue()%>"/>
<%-- textbox 3- this textbox does not repopulate correctly --%>
<html:text name="nestedBean" property="beanValue" indexed="true"/>
</logic:iterate>
</logic:iterate>
the html generated for textbox 3 is :
<input type="text" name="bean[0].nestedBean[0].beanValue" value="foo"/>
the html generated for textbox 4 is:
<input type="text" name="nestedBean[0].beanValue" value="foo">