dropdown menu "Conversion Error setting value '' for 'null Converter'"

user1423793 picture user1423793 · Jun 1, 2012 · Viewed 10.2k times · Source

So i am using seam to try to make a dropdown menu to add a delivery to a database. I'm using a drop down menu to select which employee from the database is doing the delivery. The menu loads all the employees in the database just fine but when I select one and click add, I get the error "Conversion Error setting value '(hash for employee)' for 'null Converter'.

here's the code for the dropdown menu:

<my:dropdown label="Employee ID" id="emp" value="#{deliveryPort.emp}" required="false">
                    <f:selectItem itemValue="#{null}" itemLabel="Selct One"/>
                    <s:selectItems value="#{deliveryPort.empList}" var="emp" label="#   {emp.employeeId} #{ emp.nameFirst}"/> 
               </my:dropdown>

Any help would be greatly appreciated. Thank you

Answer

flash picture flash · Jun 1, 2012

You should do 2 things to avoid this error:

  1. Make sure your class emp is implementing equals() and hashCode()
  2. Use an converter to convert your selected value before passing it to the backing bean

BalusC wrote a nice tutorial about converters and how to use them.