I have a form bean with an attribute implemented as an ArrayList (a recent
feature).

Form page works fine when I fill the ArrayList with strings to display in an
indexed <html:text> field.. No problem.

But submitting/processing the form has some trouble. I notice that unless I
pre-allocate the ArrayList in the reset() method to the length required to
accept all of the input fields, the "PropertyUtils" fails when it tries to
post the form data in the array:

<Apr 24, 2002 10:20:24 AM CDT> <Error> <HTTP> <101017>
<[WebAppServletContext(56
83213,admin,/admin)] Root cause of ServletException
java.lang.IndexOutOfBoundsException: Index: 28, Size: 0
        at java.util.ArrayList.RangeCheck(ArrayList.java:491)
        at java.util.ArrayList.set(ArrayList.java:323)
        at
org.apache.commons.beanutils.PropertyUtils.setIndexedProperty(Propert
yUtils.java:1264)
        at
org.apache.commons.beanutils.PropertyUtils.setIndexedProperty(Propert
yUtils.java:1170)
        at
org.apache.commons.beanutils.PropertyUtils.setNestedProperty(Property
Utils.java:1466)
        at
org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.
java:1498)
        at
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:613)
        at
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:952)
        at
org.apache.struts.action.RequestProcessor.processPopulate(RequestProc
essor.java:795)
        at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:244)
        at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:110
9)
        at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:470)

Normally I might be okay with including code like this in the form bean
reset method:

control = new ArrayList();
for (int jj = 0; jj < 31; jj++) {
  control.add(new String());
}

This works, but I dislike having to guess how many entries will be needed in
the ArrayList to handle the form fields. In my case the number of fields is
the number of days in the month (28-31)..

Putting the form bean in the session and not wiping the list in the reset()
method might work, but that's a hack not a solution.  Shouldn't the
"setIndexedProperty()" method in the PropertyUtils be a little more
forgiving about the current length of the target array or ArrayList?



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to