struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wendy Smoak <>
Subject Using ArrayList instead of String[] properties
Date Fri, 09 Jan 2004 21:46:27 GMT

I have a String[] property in a DynaValidatorForm.  It works fine with
multiple checkboxes and accepts multiple selections.

Now I need to do an "advanced" user interface, where the user can enter
the information in text boxes and click 'Add'.  Behind the scenes I need
to populate that String[] property (which is named 'accounts').

I don't want to deal with checking the size of the array and the
inevitable out of bounds exceptions, so I thought ArrayList would be a
better choice.  However, when I change to ArrayList, including

  <form-property     name="accounts"      type="java.util.ArrayList"/>

BeanUtils complains when I submit the form that has the multiple

  org.apache.commons.beanutils.ConversionException: Cannot assign value
of type 
  'java.lang.String' to property 'accounts' of type

The docs indicate that ArrayList is allowed in DynaActionForms (mine is
a DynaValidatorForm):

The multibox tag is:
<c:forEach items="${accountMap[]}"
var="account" >
    <html-el:multibox property="accounts">
       <c:out value="${account.key}"/>
    <c:out value="${account.key}"/>&nbsp;
    <c:out value="${account.costCenterDesc}"/>

Which correctly renders checkboxes such as
<input type="checkbox" name="accounts"
value="55_U_ABCD1234">55_U_ABCD1234&nbsp;Some Account<br/>
<input type="checkbox" name="accounts"
value="66_S_EFGH5678">66_S_EFGH5678&nbsp;Some Other Account<br/>

Any idea what I'm doing wrong, or is there a better way to do this?  

Wendy Smoak
Application Systems Analyst, Sr.
ASU IA Information Resources Management 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message