yes the code was ok - in fact the issue was the fact the formBean was in request scope in struts-config.xml - changing it to session sorted it out
-----Original Message----- From: Mark Lowe [mailto:[EMAIL PROTECTED] Sent: 13 March 2003 17:15 To: Struts Users Mailing List Subject: Re: ArrayList set method in nested bean- confusion should be fine.. to add a new row you can do so using the set's on the formBean in you action class... Gioved�, 13 mar 2003, alle 18:10 Europe/Rome, Huw Jones ha scritto: > I have a nested bean where beanA (courseBean) stores an ArrayList of > bean2 > (event). > > I can dump out the ArrayList no problem but I can't seem to make the > set > method run. So here are some code snippits. > > JSP > > <logic:notEmpty name="courseEventForm" property="courseBean.events"> > <html:text name="courseEventForm" property='<%= "courseBean.events[" > + cnt > + "].startDate" %>' size="12" maxlength="12"/> > </logic:iterate> > > So produces HTML > <input type="text" name="courseBean.events[0].startDate" > maxlength="12" > size="12" value=""> > <input type="text" name="courseBean.events[1].startDate" > maxlength="12" > size="12" value=""> > > etc > > In formbean > > public CourseEventForm () { > this.course = new Course(this); > } > etc > > > In my Course Bean set/get methods > > public Course (CourseEventForm parent) { > this.parentBean = parent; > this.eventList = new ArrayList(); > } > public Object[] getEvents() { > return eventList.toArray(); > } > > public void setEvents(Object[] newEventList) { > this.eventList = new ArrayList(); > for (int i=0; i<newEventList.length; i++) { > this.eventList.add(newEventList[i]); > } > } > > > I'm basically trying to implement an add button which adds another > instance > of an event in the form but > I get array out of bounds error. If the set method ran it should > increase > the array length as it needs - I'm thinking. > > Any one know what's going wrong here - do I need another method in the > Course Bean > > Thanks > > Huw Jones > > > > --------------------------------------------------------------------- > 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]

