struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Grebac <martin.gre...@sun.com>
Subject Re: again ArrayList and javax.servlet.ServletException: BeanUtils .populate exception
Date Fri, 27 Sep 2002 13:44:17 GMT
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
>
> thorsten_soebirk@agilent.com 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:martin.grebac@sun.com]
>>> 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
>>>
>>>
>>>
>>> thorsten_soebirk@agilent.com 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:struts-user-unsubscribe@jakarta.apache.org>
>>  
>>
>>> For additional commands, e-mail: 
>>> <mailto:struts-user-help@jakarta.apache.org>
>>>
>>>   
>>
>>
>>
>> --
>> To unsubscribe, e-mail:   
>> <mailto:struts-user-unsubscribe@jakarta.apache.org>
>> For additional commands, e-mail: 
>> <mailto:struts-user-help@jakarta.apache.org>
>>  
>>
>
>
> --
> To unsubscribe, e-mail:   
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: 
> <mailto:struts-user-help@jakarta.apache.org>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message