If your form is "session" scoped then the collection of beans will exist when your form is submitted back. For request scope, which I presume you are using, then you will need to generate your collection of beans. Theres been quite a bit of discussion on this list about how to do this - with a number of people using a LizyList class from Commons collections.
http://cvs.apache.org/viewcvs.cgi/jakarta-commons/collections/src/java/org/apache/commons/collections/list/LazyList.java Also the LazyValidatorForm I wrote caters for this - take a look at the get(String name, int index) method in LazyValidatorForm for an example of what you need to do http://www.niallp.pwp.blueyonder.co.uk Niall ----- Original Message ----- From: "Lachdanan" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, April 19, 2004 4:52 PM Subject: logic:iterate over a collection of non-simple objects, how to fill them after submit > Hello, > > I have the following problem: > > I use a collection of objects of type AClass which have another collection > as an attribute (<%="anAttribute["+index.intValue()+"]"%>). > > <logic:iterate id="ABean" type="de.abc.test.AClass" name="AForm" > property="aCollection" indexId="index"> > <TR> > <TD> > <html:select name="ABean" > property='<%="anAttribute["+index.intValue()+"]"%>' size="1"> > <html:options name="AForm" property="anIDList" > labelProperty="aNameList"/> > </html:select> > </TD> > </TR> > </logic:iterate> > > The direction Form --> JSP works well. > In my opinion, after SUBMIT Struts should do the following: > create some instances of ABean > fill them with 'setAnAttribute[index]' > create a collection > fill it with the ABean Instances > call AForm.setACollection(collection) > > But this doesnt work, and when I look at the HTML source code it seems that > Struts forgets the ABean and tries to call AForm.setAnAttribute(value, > index) which wont work of course. > > Does anyone have some good advice for me? > Thx in advance!! > > Lachdanan > > P.S. I tried to use > <html:select name="ABean" property="anAttribute" size="1" > indexed="true"> > but that didnt work? Any ideas why not? I thought Struts would create > 'property="anAttribute[index]"' or similar?! Hmm, is it possible that it > doesnt work because the method signature is getAnAttribute(int) instead of > getAnAttribute(Integer)?? I'll try in the meantime :-) > > > > > --------------------------------------------------------------------- > 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]