No exception if you replace your ArrayList by a String[] (for the properties used by the select tag).
Vincent Berruchon wrote: > I get a "BeanUtils.populate() exception" when a form with a multiple > select is posted (with struts 1.0.2, Martin reported this Bug a few days > ago - bugzilla bug id #: 13075) : > "javax.servlet.ServletException: BeanUtils.populate > at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:774) > ..." > > I don't know if it can have a link, but I'm not sure to understand this > warning about the "select" tag ( in > webapps/struts-documentation/struts-html.html#select): > - > WARNING: In order to correctly recognize cases where no selection at all > is made, the ActionForm bean associated with this form must include a > statement resetting the scalar property to a default value (if multiple > is not set), or the array property to zero length (if multiple is set) > in the reset() method. > - > > So in my formBean, in the reset() method I've put: > " this.selectedValues = new ArrayList(); " > instead of > "this.selectedValues = null; " > > But I'm not sure it really respect the warning?? > What mean "a zero length ArrayList": > not null I suppose... > should I use the other constructor : "new ArrayList(0)" ? > > This is the first point. > But in fact, all that got no influence on this populate exception with > multiple select. > Is there another way to do with a "multiple select"? > > Thanks > Vincent > > Martin Grebac wrote: > >> Hi, >> so here is the Bugid: >> >> >> 13075 >> >> . May I expect something's gonna happen with it, or will it die in the >> deeps of the bug database ;O)) >> >> Martin >> >> >> Martin Grebac wrote: >> >>> Yes, I built everything anew, and also restarted server. I forgot to >>> mention I'm using Struts 1.0.2 (but I think it's not relevant). Since >>> Mohan has almost the same problem and everything we are using seems >>> to be OK for you, and also according to the documentation it should >>> work, I assume this is a bug. I'm gonna enter it into bugzilla, but >>> it's rather serious for me, because I don't have any workaround for >>> that. >>> Martin >>> >>> [EMAIL PROTECTED] wrote: >>> >>>> What you have there looks right, so silly question (maybe): have you >>>> reloaded the web application after recompiling the ModulePathForm >>>> class? >>>> >>>> - Thorsten >>>> >>>> >>>> >>>>> -----Original Message----- >>>>> From: Martin Grebac [mailto:[EMAIL PROTECTED]] >>>>> Sent: 27 September 2002 13:32 >>>>> To: Struts Users Mailing List >>>>> Subject: Re: again ArrayList and javax.servlet.ServletException: >>>>> BeanUtils .populate exception >>>>> >>>>> >>>>> No, it doesn't work also. I get the same exception everytime. >>>>> >>>>> I want to have the possibility to select multiple folders, so I >>>>> did what you suggested: added property selectedFolders of type >>>>> String[], so I added this code to my ModulePathForm: >>>>> >>>>> private String[] selectedFolders; >>>>> >>>>> public String getSelectedFolders(int index) { >>>>> return this.selectedFolders[index]; >>>>> } >>>>> public String[] getSelectedFolders() { >>>>> return this.selectedFolders; >>>>> } >>>>> public void setSelectedFolders(int index, String >>>>> selectedFolders) { >>>>> this.selectedFolders[index] = selectedFolders; >>>>> } >>>>> public void setSelectedFolders(String[] selectedFolders) { >>>>> this.selectedFolders = selectedFolders; >>>>> } >>>>> >>>>> and the jsp page looks the same as you wrote: >>>>> >>>>> <html:select property="selectedFolders" multiple="true"> >>>>> <html:options property="folders"/> >>>>> </html:select> >>>>> >>>>> I really don't know where is the problem. Really appreciate any >>>>> other hints. >>>>> >>>>> Thanks, >>>>> Martin >>>>> >>>>> >>>>> >>>>> [EMAIL PROTECTED] wrote: >>>>> >>>>> >>>>> >>>>>> Hi, >>>>>> >>>>>> I think the problem is that your <html:select...> and >>>>> >>>>> >>>>> >>>>> <html:options...> tags both reference the "folders" property. >>>>> Judging by your code, the <html:options...> tag is doing what you >>>>> expect i.e. getting the list of folders the user can select from. >>>>> However, your <html:select...> tag is telling Struts to try to >>>>> assign the selected folder back to the form bean by calling >>>>> setFolders (albeit indirectly via BeanUtils.populate), but >>>>> setFolders is expecting an ArrayList rather than a single item >>>>> from a list which your submit is sending back as a String. >>>>> >>>>> >>>>>> I suspect what you need to do is introduce an additional >>>>> >>>>> >>>>> >>>>> property called e.g. selectedFolder into your form bean. Your jsp >>>>> would then look like this: >>>>> >>>>> >>>>>> <html:select property="selectedFolder" multiple="true"> >>>>>> <html:options property="folders"/> >>>>>> </html:select> >>>>>> >>>>>> ...and you will need corresponding setter and getter methods >>>>> >>>>> >>>>> >>>>> in the bean. You can then also have getSelectedFolder() return a >>>>> default value. >>>>> >>>>> >>>>>> Regards, >>>>>> Thorsten >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>>> Hi, >>>>>>> I'm looking for any hint or advice. I've got code like this on my >>>>>>> jsp page: >>>>>>> >>>>>>> <html:select property="folders" multiple="true"> >>>>>>> <html:options property="folders"/> >>>>>>> </html:select> >>>>>>> >>>>>>> property "folders" is a property of my "ModulePathForm" bean: >>>>>>> >>>>>>> /* ModulePathForm.java */ >>>>>>> public class ModulePathForm extends ActionForm{ >>>>>>> >>>>>>> private ArrayList folders; >>>>>>> >>>>>>> public ModulePathForm() { >>>>>>> super(); >>>>>>> folders = new ArrayList(); >>>>>>> } >>>>>>> >>>>>>> public ArrayList getFolders() { >>>>>>> return this.folders; >>>>>>> } >>>>>>> >>>>>>> public void setFolders(ArrayList folders) { >>>>>>> this.folders = folders; >>>>>>> } >>>>>>> } >>>>>>> >>>>>>> the values from the bean are shown, but when I click Submit, I >>>>>>> get this exception: >>>>>>> >>>>>>> javax.servlet.ServletException: BeanUtils.populate >>>>>>> at >>>>>>> org.apache.struts.util.RequestUtils.populate(RequestUtils.java:774) >>>>>>> at >>>>>>> org.apache.struts.action.ActionServlet.processPopulate(ActionS >>>>>>> ervlet.java:2061) >>>>>>> at >>>>>>> org.apache.struts.action.ActionServlet.process(ActionServlet.j >>>>>>> ava:1563) >>>>>>> at org.apache.struts.action.ActionServlet.doPost(ActionServlet. >>>>>>> >>>>>> >>>>>> >>>>>> >>>>> java:509) >>>>> >>>>> >>>>>>> ..... >>>>>>> root cause: >>>>>>> >>>>>>> java.lang.IllegalArgumentException: argument type mismatch >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> To unsubscribe, e-mail: >>>>> >>>>> >>>>> >>>> <mailto:[EMAIL PROTECTED]> >>>> >>>> >>>>> For additional commands, e-mail: >>>>> <mailto:[EMAIL PROTECTED]> >>>>> >>>>> >>>> >>>> >>>> >>>> >>>> >>>> -- >>>> To unsubscribe, e-mail: >>>> <mailto:[EMAIL PROTECTED]> >>>> For additional commands, e-mail: >>>> <mailto:[EMAIL PROTECTED]> >>>> >>>> >>> >>> >>> -- >>> To unsubscribe, e-mail: >>> <mailto:[EMAIL PROTECTED]> >>> For additional commands, e-mail: >>> <mailto:[EMAIL PROTECTED]> >> >> >> >> > > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

