• 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

Spring Combobox selection with HashMap entries

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic