File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Application Frameworks and the fly likes Spring Combobox selection with HashMap entries Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Spring Combobox selection with HashMap entries" Watch "Spring Combobox selection with HashMap entries" New topic

Spring Combobox selection with HashMap entries

sudheshna Iyer
Ranch Hand

Joined: Aug 20, 2004
Posts: 71
Problem in diplaying and collecting values from jsp combo box:

I have the following in jsp:

<c:if test="${not empty customer.states}">
<form:select path="state" items="${customer.states}"/>

HashMap<String, String> state (stateCode, stateDesc)==> Should contain seleted value

HashMap<String, String> states ==> Contains list of stateCode, stateDesc

org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'command' on field 'state': rejected value [IT012]; codes [typeMismatch.command.state,typeMismatch.state,,typeMismatch]; arguments [org.springframework.context.sup
port.DefaultMessageSourceResolvable: codes [command.state,state]; arguments []; default message [state]]; default message [Failed to convert property value of type [java.lang.String] to required type [java.util.Hash
Map] for property 'state'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [
java.lang.String] to required type [java.util.HashMap] for property 'state': no matching editors or conversion st
rategy found]

I guess I have to set up property editors. Is that correct? If yes, can anybody provide simple example of setting up
property editors?
I agree. Here's the link:
subject: Spring Combobox selection with HashMap entries