How to get the selected values? And depending on how many values ​​I have chosen, change the label on the element? I tried to write a script, but nothing happened, because update label does not occur. Those. when all values ​​are selected, the word "All" is displayed. But when I remove the checkbox, it does not disappear. And if you add an update, the menu with the checkbox will be minimized.

<p:selectCheckboxMenu value="#{managedBean.filterDepartmentIds}" id="emdepartmentList" widgetVar="emdepartmentList" label="..." required="#{empty managedBean.filterDepartmentIds}" rendered="#{managedBean.isCreateMode}" styleClass="-fill" multiple = "true"> <p:ajax update="toolTipFade"/> <p:ajax process="@this" update="test1" event="toggleSelect" oncomplete="if (PF('emdepartmentList').inputs.filter(':checked').length === #{managedBean.departmentList.size()}){ PF('emdepartmentList').label.text('#{msg['all']}'); } else { PF('emdepartmentList').label.text('...'); }"/> 

I use Primefaces 5.3. I cannot upgrade to a newer version due to certain circumstances.

  • It is possible an example with server side. - Artem Poteshkin
  • HardCode is also accepted - Artem Poteshkin

1 answer 1

Question resolved by adding

 <p:ajax process="@this" event="change"/>