I am pretty new to JSF and was trying to the following
I have a p:selectCheckboxMenu which have the list of employees and one among them will be made their leader. So I was trying to create a p:selectCheckBoxMenu which will give me the list. The selected names will be stored in a list and a p:selectOneMenu will be updated, which will again present those selected names and one among them will be selected(from p:selectOneMenu). Basically from p:selectcheckbox we can select many names. and p:selectonemenu we will select one among those selected.
My Code :
<p:outputLabel for="teamMemb" value="Select Team Members"></p:outputLabel>
<p:selectCheckboxMenu id="teamMemb" value="#{teamMaintainanceController.teamMemb}">
<p:ajax update="teamLeader"></p:ajax>
<f:selectItems value="#{employeeMaintainanceController.possibleManagerList}"></f:selectItems>
</p:selectCheckboxMenu>
<p:outputLabel for="teamLeader" value="Select Team Leader"></p:outputLabel>
<p:selectOneMenu id="teamLeader" value="#{teamMaintainanceController.teamLeader}">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItems itemLabel="#{teamMaintainanceController.teamMemb}" itemValue="#{teamMaintainanceController.teamMemb}" value="#{teamMaintainanceController.teamMemb}"/>
</p:selectOneMenu>
<p:commandButton id="applyBtn" value="Add" ajax="false" actionListener="#{teamMaintainanceController.addTeam}"/>
Everything is enclosed in a form. Now the problem is, When I select the values from p:selectCheckboxMenu the p:selectOneMenu gets updated and shows the list of people that were selected earlier, but when I select one of them and click on the button, it shows validation error and console shows that value is required. I checked and the null value is going when we click on button.
I don't really get why. Please help
P.S : I am using @conversationScoped