You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Scherger, Derek" <De...@encana.com> on 2004/04/14 23:32:37 UTC

Logic:iterate with html:text indexed properties

I'm having a bit of a problem with the html:text tag in an indexed
context... 
my form bean is arranged as follows:

FormBean
	InnerBean aaa;
	InnerBean bbb;

InnerBean 
	List list;

SimpleBean 
	String name;
	Integer value;

Where the elements of the InnerBean list are SimpleBean's. On my jsp page I
have the following, inside of and html:form tag.

<logic:iterate id="simple" name="formBean" property="aaa.list"
type="SimpleBean">
<html:text name="simple" property="value" indexed="true"/>
</logic:iterate>

The html that gets generated by this has text inputs named simple[0].value,
simple[1].value etc..
When this is submitted it's trying to set these indexed values directly on
the formBean rather than on the proper inner bean's list. i.e.
BeanUtils.populate(formBean, {simple[0].value=123, simple[1]=456})

I'm thinking of addint a getSimple(int index) method to my form bean to
return the indexed element from aaa.list but this seems like somewhat of a
hack. It seems that the html:text tag needs some way of generating inputs
with a prefix to the specified name, in my case aaa.list so that the inputs
are named "aaa.list.simple[0].value" etc.

Is there a better way to handle situations like this, or does my form bean
need to be less structured to work properly?

Thanks,
Derek