1
votes

I am Developing such application in which there is Hibernate Many to One Relationship between Employee and Designation. While Inserting New Employee, I am Creating Dynamic Options(which comes from Designation Table present in Database) of Select Menu for Designation. I can Create options as follow in xhtml:

 <b:selectOneMenu value = "#{loginBean.designationVo}"> 
     <f:selectItems value = "#{loginController.designationListByInsert()}" var = "field" itemLabel = "#{field.designation}" itemValue = "#{field.designationId}"/>
    </b:selectOneMenu>

In Above Code, designationListByInsert() method will return List of Designation, Now I want to set DesignationName as itemLabel so user can see only Name of Designation along with it I want DesignationId as itemValue, but I can't set itemValue as shown in above code. It takes index value of List as itemValue. If I set DesignationId as itemLabel the it shows correct value but at same time If I Assign it to itemValue then it doesn't work. I can't understand what's wrong in my code. Please Someone help me to make it correct.

1

1 Answers

3
votes

Try this it will surely work.

Replace

itemValue = "#{field.designationId}"

by

itemValue = "#{field}"