struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Nyberg" <greg.nyb...@objectpartners.com>
Subject RE: form bean with ArrayList
Date Wed, 24 Apr 2002 16:39:28 GMT
Thanks for the response. If the reset() method simply ensures the list is
instantiated via

control = new ArrayList();

... I get the error described. It cannot be an "empty" list.

Adding the loop and pre-allocation of the list elements with empty strings
is necessary to avoid the error.  The setIndexedProperty method uses
list.set() (obvious from the stacktrace) rather than .add(), and must not
check the current length first..

-Greg

> -----Original Message-----
> From: Galbreath, Mark [mailto:Galbreath@tessco.com]
> Sent: Wednesday, April 24, 2002 11:18 AM
> To: 'Struts Users Mailing List'
> Subject: RE: form bean with ArrayList
>
>
> That's pretty weird, considering an ArrayList has an initial
> capacity of 10
> and grows automatically.  Are you sure you are re-instantiating the List
> after (I assume) dereferencing it in reset()?
>
> Mark
>
> -----Original Message-----
> From: Greg Nyberg [mailto:greg.nyberg@objectpartners.com]
> Sent: Wednesday, April 24, 2002 11:44 AM
>
> 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
>
> --
> To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>



--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message