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]

Reply via email to