Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring Combobox selection with HashMap entries

 
sudheshna Iyer
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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}"/>
</c:if>

Customer:
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.java.util.HashMap,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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic