Try using an Arraylist in your setter and getter instead of a string array.
Also System.out the setters and getters to make sure they are being called.
>From: "Michael Terry" <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: <[EMAIL PROTECTED]>
>Subject: RE: Re[2]: Multiple input fields
>Date: Mon, 20 Aug 2001 15:32:02 +0100
>
>Kent -
>
>Can you give an example of how you did this? I used an ArrayList
>in my form, with one entry per select element in my form. This
>works fine when only single options can be selected, but I can't
>get it to work with <html:select ... multiple="true">
>
>In my JSP I want to generate a variable number of multiple select
>boxes containing values taken from a Hashtable containing
>ArrayLists of beans (one entry in the Hashtable for each box):
>
> <% int n = 0; %>
> <logic:iterate id="attTab" name="attList" property="attTable">
> <%
> prop = "attList[" + n + "]";
> n++;
> %>
> <bean:define id="atts" name="attTab" property="value" />
> <html:select property="<%=prop %>" multiple="true" >
> <html:options collection="atts" property="attValKey"
>labelProperty="attValDes"/>
> </html:select>
> </logic:iterate>
>
>In the associated form bean, I use an ArrayList named attList which will
>contain the variable number of String[] arrays of selected values passed
>back from my select boxes. So I have my getter and setter thus:
>
> public String[] getAttList(int idx) {
> return (String[])attList.get(idx);
> }
>
> public void setAttList(int idx, String[] keys) {
> attList.set(idx, keys);
> }
>
>But the problem is that this collapses in BeanUtils.populate with a
>type mismatch error:
>
> javax.servlet.ServletException: BeanUtils.populate
> at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:486)
> Root cause:
> java.lang.IllegalArgumentException: argument type mismatch
> at java.lang.reflect.Method.invoke(Native Method)
> at
>org.apache.struts.util.PropertyUtils.setIndexedProperty(PropertyUtils.java:688)
>
>There is no problem when I remove the multiple=true from the select element
>and use the following:
>
> public String getAttList(int idx) {
> return (String)attList.get(idx);
> }
>
> public void setAttList(int idx, String key) {
> attList.set(idx, key);
> }
>
>I've already posted this problem once, but answer came there none.
>
>Michael
>
>-----Original Message-----
>From: Kent Roylance [mailto:[EMAIL PROTECTED]]
>Sent: Friday, August 17, 2001 2:50 AM
>To: [EMAIL PROTECTED]; Anthony Xin Chen
>Subject: RE: Re[2]: Multiple input fields
>
>
>Actually, you can do one better than that. Just pass in beans to the
>form(can have collections in them), and that way you don't have to put a
>bunch of attributes and getter/setters in your form. Of course you will
>need a getter for your bean that you put in your ActionForm. As a result,
>my ActionForms are very thin, take advantage of reuseability, better
>performance, and alot less work.
>
>Learned trial and error on this one,
>
>Kent
>
>-----Original Message-----
>From: Anthony Xin Chen [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, August 16, 2001 6:48 PM
>To: SUPRIYA MISRA
>Subject: Re[2]: Multiple input fields
>
>
>Hello there,
>
>Although I have not tried it personally, I read from the list that it
>can be done if your ActionForm provides a setter which takes a
>collection and a getter which returns a collection.
>
>
>Thursday, August 16, 2001, 5:03:15 AM, you wrote:
>
>SM> No the last category will overwrite the previous ones. You need to add
>an
>SM> integer to category.
>
>SM> <%int x= 0 ;%>
>SM> <TD><input type="text" name="category<%=x>" value=""></TD>
>SM> <%x++;%>
>SM> <TD><input type="text" category<%=x>" value=""></TD>
>
>SM> request.getParameterValues("category0")
>SM> request.getParameterValues("category1")
>
>SM> The best option is to loop it the value of x times;
>
>
> >>From: [EMAIL PROTECTED] (Andrew Myers)
> >>Reply-To: [EMAIL PROTECTED]
> >>To: [EMAIL PROTECTED]
> >>Subject: Multiple input fields
> >>Date: Thu, 16 Aug 2001 02:22:02 -0400
> >>
> >>Is it possible to have multiple input fields with the same name?
> >>
> >>Eg. In regular HTML I would do this
> >>
> >><form action="blah">
> >>
> >><TABLE>
> >> <TR>
> >> <TD>Category</TD>
> >> <TD>Description</TD>
> >> </TR>
> >>
> >> <TR>
> >> <TD><input type="text" name="category" value=""></TD>
> >> <TD><input type="text" name="description" value=""></TD>
> >> </TR>
> >>
> >> <TR>
> >> <TD><input type="text" name="category" value=""></TD>
> >> <TD><input type="text" name="description" value=""></TD>
> >> </TR>
> >>
> >>...
> >>
> >></TABLE>
> >>
> >>
> >></form>
> >>
> >>Then when access all the parameters by calling
> >>request.getParameterValues("category")
> >>Can ActionForm Beans handle multiple values with the same field name?
>If
> >>so how is this achieved?
> >>
> >>Thanks,
> >>Andrew.
> >>
> >>
> >>__________________________________________________________________
> >>Your favorite stores, helpful shopping tools and great gift ideas.
> >>Experience the convenience of buying online with Shop@Netscape!
> >>http://shopnow.netscape.com/
> >>
> >>Get your own FREE, personal Netscape Mail account today at
> >>http://webmail.netscape.com/
> >>
>
>
>SM> _________________________________________________________________
>SM> Get your FREE download of MSN Explorer at
>http://explorer.msn.com/intl.asp
>
>
>
>--
>Best regards,
> Anthony
>
>
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp