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]>

Reply via email to