Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html:select multiple="true" How to return multiple selections?

 
Jesse J Johnson Jr
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having trouble returning the "multiple selected" options from a list. When I initially 'submit' the JSP, my list gets populated correctly. The user is then allowed to make multiple selections from the list. After 'submit', the server reports "java.lang.IllegalArgumentException: argument type mismatch".

Of course, if I select nothing from the list, the server does not complain.

My struts tags...
<html:select property="dto.geoRegionNames" multiple="true" size="10">
<html ptionsCollection property="dto.configGeoRegions" label="name" value="name"/>
</html:select>

On this page, I am displaying a list of states selected from a previous page. After the first 'submit' the user will be allowed to refine her selection from the list displayed.

The data type of dto.geoRegionNames is ArrayList.
The dto.configGeoRegions is a complex data type.

I would like to structure this so that the page sends multiple selections back on submit. Any ideas?

Thank you.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<html:select> will only support a simple String array, and not an ArrayList. You will have to restructure your code to allow for this limitation. One thing you might do is code a String array as a direct attribute of the form bean, and then when the form is read, have your action class convert the String array to an ArrayList and place it in your Data Transfer Object.
 
Jesse J Johnson Jr
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Merril, thanks for your suggestion. I'll give it a try.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic