I am using primefaces 5.2.
I have a<p:selectCheckboxMenu>
within a <p:dataTable>
for selecting multiple values. The label of the selectCheckboxMenu reads 'Select'. I want to update the label of the checkboxMenu to be 'Edit' if some value is selected or else keep it as 'Select' if nothing is selected. I want this to happen only after the selectCheckboxMenu is closed.
I referred the stackoverflow question How to update the label of p:selectCheckboxMenu without the component being closed after ajax call in primefaces?. But after selecting some value from the checkboxMenu, the menu blinks for a moment( ajax call happens and the label is updated) and it reapperars. But due to the blink happening in between , the behavior is weird. for eg. If I select the first checkbox within the menu, and then immediately second one, it blinks and when it reappears, only one checkbox would be checked. Here is the code snippet:
<p:column headerText="Apply To" style="width:120px;text-align:center;">
<p:selectCheckboxMenu id="applyToId" value="#{rule.accountTypes}"
label="#{rule.accountTypeLabel}" widgetVar="accntType">
<f:selectItems value="#{controller.customerAccTypes}" />
<p:ajax oncomplete="PF('accntType').show()"
listener="#{controller.populateLabel(rule,event)}"
update="applyToId"></p:ajax>
</p:selectCheckboxMenu></p:column>
The controller method:
public void populateLabel(NewRules rule,AjaxBehaviorEvent event) {
if (rule.getAccountTypes().length == 0) {
rule.setAccountTypeLabel("Select One");
} else {
rule.setAccountTypeLabel("Edit");
}}
I am not sure if I am doing something wrong. Thanks in advance.