Converter class throwing exception java.lang.IllegalArgumentException

前端 未结 2 1278
太阳男子
太阳男子 2021-01-24 15:50

I have p:selectOneMenu in my JSF page and when I run my JSF page I am getting the following exception from Converter class.

java.lang.IllegalArgumentException: o         


        
相关标签:
2条回答
  • 2021-01-24 16:12

    In your getAsObject method you're doing nothing with your reached value. Here you're going to receive your #{emp.employeeNumber}, so you have to convert it into an Employee (probably you'll have to implement a method which loads an Employee by id using service locator) and return the object itself.

    You're also referencing the convertor with an EL (#{employeeConverter}), you have to do it in a direct way. Finally, the List of elements has to be composed by SelectItem, in order to make f:selectItems tag work.

    0 讨论(0)
  • 2021-01-24 16:32

    Don't assign the string to the item value, you need to assign the converted object (Employee) itself.

    change to itemValue="#{emp}"

    See BalusC answer on this question.

    0 讨论(0)
提交回复
热议问题