While messing around with things a minute ago, I found that the only setter method in my ActionForm that gets called is
public void setIds (String[] ids), but when it does get called I get the following error: javax.servlet.ServletException: BeanUtils.populate at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:774) at org.apache.struts.action.ActionServlet.processPopulate(ActionServlet.java:20 61) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1564) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) ... root cause: java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.struts.util.PropertyUtils.setSimpleProperty(PropertyUtils.java:98 8) at org.apache.struts.util.PropertyUtils.setNestedProperty(PropertyUtils.java:90 4) at org.apache.struts.util.PropertyUtils.setProperty(PropertyUtils.java:932) at org.apache.struts.util.BeanUtils.populate(BeanUtils.java:509) at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:772) at org.apache.struts.action.ActionServlet.processPopulate(ActionServlet.java:20 61) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1564) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) So it must not like the String[] part. However, I already HAVE the following methods defined but they don't get run: public void setIds (java.util.ArrayList ids) public void setIds (Object[] ids) public void setIds (int i, String id) public void setIds (int i, Object id) If I comment out setIds(String[] ids) completely, it runs right through but never populates the ids field. I guess it assumes that's a "read only" field. What "signature" is it looking for in the setIds method if not String[]? ----- Original Message ----- From: "Ian Hunter" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Monday, February 24, 2003 10:20 AM Subject: Re: <html:select> "multiple" problems So I have to create Collection-type classes to hold the values so that the <select> tag can populate them? That doesn't make sense, when with a non-multiple <select> I can just refer to a single String property. I looked at the example and I still don't have an answer to my original question: What method(s) in the ActionForm class get called to set the values from a multiple select box, if the JSP looks like this: <html:form name="attendanceForm" action="postattendance" type="AttendanceForm"> <html:select property="ids"> <html:option value="0">Zero</html:option> <html:option value="1">One</html:option> <html:option value="2">Two</html:option> </html:select> </html:form> Surely <html:select> can handle hard coded options? I just can't figure out which setter method "profile" would get called here, and the example code (TestBean.java) has SO many different getter/setter things going on that I can't figure which goes with what from the JSP. ----- Original Message ----- From: "Sri Sankaran" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Monday, February 24, 2003 9:44 AM Subject: RE: <html:select> "multiple" problems The example referenced by Jörg Maurer is available in Struts 1.0.2 as well. It includes the following <tr> <th align="right">Multiple Select Allowed:</th> <td align="left"> <html:select property="multipleSelect" size="10" multiple="true"> <html:options name="multipleValues" labelName="multipleValues"/> </html:select> </td> </tr> which is identical to what you are trying to accomplish. As you are probably aware, the property "multipleSelect" here ("ids" in your case) holds the selected values while "multipleValues" is the collection of available options. However the snippet you have sent in one of your emails has <html:select property="ids" multiple="true"> <html:options property="ids"/> </html:select> Looking at your form bean definition I think what you are trying to do is display "Zero", "One" but have the values "0" and "1" submitted. What you have to do is to set up LabelValueBeans with the necessary name and value. I *think* LabelValueBeans are part of Struts 1.0.2; if not simply create a JavaBean with "name" and "value" properties and make a collection of them. Look at the docs for <html:options> on how to use it. Also, ensure that your <html:select> is inside a <html:form> Sri -----Original Message----- From: Ian Hunter [mailto:[EMAIL PROTECTED] Sent: Sunday, February 23, 2003 11:03 PM To: Struts Users Mailing List Subject: Re: <html:select> "multiple" problems OK. Let me narrow down my question somewhat. In Struts 1.0.2, what method in an ActionForm is called after an input JSP containing an <html:select multiple="true" property="ids"> tag, assuming the property ids is a String[]? Does it look like public void setIds(Object[] ids) or public void setIds(String[] ids) or public void setIds(ArrayList ids) or what? Seems like no matter what setter method I provide, it doesn't get called. ----- Original Message ----- From: "Ian Hunter" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Sunday, February 23, 2003 9:20 PM Subject: <html:select> "multiple" problems > AAAARGGGGGH!!!! > > I would give one of my legs right now for a working example of an > <html:select multiple="true"> usage that populates an array in an > ActionForm. > > Help? > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]