• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Populating select boxes from Database

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm using database top populate a select box in the JSP. First time when the JSP is called, the select box is populated correctly.
I use the following code for this:
-----------------------------------------------------------------------------------------------------------------------------------------------------------
<bean efine id="selProject" name="projectsForm" property="selProject" type="java.util.ArrayList"/>
<html:select property="selProject" size="10" style="width:180px" onchange="projectsOnChange();">
<html ptions collection="selProject" property="value" labelProperty="label" />
</html:select>
-----------------------------------------------------------------------------------------------------------------------------------------------------------
"selProject" is an attribute in my form bean which is of type ArrayList. This array list contains objects of type
OptionLabelValue.
When i click the save button the following error occurs.
-----------------------------------------------------------------------------------------------------------------------------------------------------------
exception
javax.servlet.ServletException: BeanUtils.populate
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:774)
at org.apache.struts.action.ActionServlet.processPopulate(ActionServlet.java:2061)
...........
root cause
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
...........
-----------------------------------------------------------------------------------------------------------------------------------------------------------
All my form beans are in request scope.
Any suggestions please.
regards,
Dinesh
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your problem is at <html:select property="selProject" ...
This property needs to hold whatever item was selected, not an ArrayList. So you probably need to add an attribute to your form bean to hold whatever value was selected, and change the property attribute of your select tag accordingly.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic