Another solution ... use "lazy" ActionForms - then you don't need to do anything.
http://www.niallp.pwp.blueyonder.co.uk/#lazydynabean Niall ----- Original Message ----- From: "Sebastian Hennebrueder" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Thursday, September 16, 2004 6:17 PM Subject: Re: Need example of using DynaActionForm with ArrayList (1.1) > Hallo, > > I struggled with the same problem for many days and found finally a > workaround. Arron pointed me to a much better workaround for the problem. > > I compiled a tutorial explaining the background and possible workarounds. > > The tutorial is on my website > > http://www.laliluna.de/tutorial/struts-dynamic-forms/struts-dynamic-forms-tutorial.html > > You will find the problem quite offen related to > > *java.lang.IndexOutOfBoundsException* > when using > at org.apache.commons.beanutils.BeanUtils.populate > > or *java.lang.ArrayIndexOutOfBoundsException* > > dynamic forms > > Regards Sebastian > > Antony Paul wrote: > > >Thanks for the reply. I scraped the original code and replaced it with my > >own implementation using Map. I will experiment your suggestions in the next > >opportunity. > > > >rgds > >Antony Paul > > > >----- Original Message ----- > >From: "Matt Bathje" <[EMAIL PROTECTED]> > >To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > >Sent: Tuesday, September 14, 2004 7:14 PM > >Subject: Re: Need example of using DynaActionForm with ArrayList (1.1) > > > > > > > > > >>Antony Paul wrote: > >> > >> > >>>Hi all, > >>> Sorry if it is a repost. > >>> Using Struts 1.1. > >>> I have an ActionForm in which displays an array of items. I want to > >>> > >>> > >use > > > > > >>>DynaValidatorForm here which uses ArrayList as property holders. I am > >>> > >>> > >able > > > > > >>>to pre-populate the form. I have trouble in displaying the values and on > >>>submission nothing is populated. If somebody can give an example it will > >>> > >>> > >be > > > > > >>>very useful to me. > >>> > >>>Struts-config.xml > >>>------------------ > >>><form-bean name="PriceForm" > >>>type="org.apache.struts.validator.DynaValidatorForm"> > >>> <form-property name="productid" type="java.util.ArrayList"/> > >>> <form-property name="productdesc" type="java.util.ArrayList"/> > >>></form-bean> > >>> > >>>JSP > >>>--- > >>>logic:iterate name="PriceForm" property="productid" id="pid" > >>>indexId="index"> > >>> <tr> > >>> <//html:hidden property='<%="productid["+index+"]"%>'/> > >>> <td><html:text property="productdesc" indexed="true"/> > >>> > >>> <td><//html:text property='<%="productdesc["+index+"]"%>'/> > >>> > >>> </tr> > >>> </logic:iterate> > >>> > >>>I tried using indexed attribute. Then HTML generated is > >>> > >>><input type="text" > >>> > >>> > >name="org.apache.struts.taglib.html.BEAN[0].productdesc" > > > > > >>>value="[product desc 0]"> > >>> > >>>See the value is in braces. > >>> > >>>If I use <html:text property="productdesc" indexed="true"/> I get > >>> > >>>java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 > >>> > >>>What is wrong ?. > >>> > >>>rgds > >>>Antony Paul > >>> > >>> > >>Antony - I've never done this with an arraylist myself, just arrays - > >>but in my experience the error you are getting comes up when struts > >>can't figure out the length of the collection you are trying to iterate > >>over. This usually happens when the form is being put in the request > >>scope and not in the session scope. > >> > >>Is it possible you could post the relevant portions of your "loader" > >>class, as well as the action mappings for the loader and submit forms? > >> > >>The other alternative you may have is to look into using Niall's > >>LazyList implementation. It is supposed to get rid of a lot of > >>headache's like that. (Just google for struts lazylist and you'll see > >>what you need.) > >> > >>Matt > >> > >> > >> > >>--------------------------------------------------------------------- > >>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] > > > > > > > > > > > --------------------------------------------------------------------- > 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]