title: Primefaces selectCheckboxMenu to update label when it is closed
body: <p>I am using primefaces 5.2.
  I have a<code>&lt;p:selectCheckboxMenu&gt;</code> within a <code>&lt;p:dataTable&gt;</code> 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. </p>
  
  <p>I referred the stackoverflow question <a href="https://stackoverflow.com/questions/9964759/how-to-update-the-label-of-pselectcheckboxmenu-without-the-component-being-clos">How to update the label of p:selectCheckboxMenu without the component being closed after ajax call in primefaces?</a>. 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>
  
  <pre><code>&lt;p:column headerText="Apply To"  style="width:120px;text-align:center;"&gt;
      &lt;p:selectCheckboxMenu id="applyToId" value="#{rule.accountTypes}" 
              label="#{rule.accountTypeLabel}" widgetVar="accntType"&gt;                                      
                  &lt;f:selectItems value="#{controller.customerAccTypes}" /&gt;
                      &lt;p:ajax oncomplete="PF('accntType').show()"
                              listener="#{controller.populateLabel(rule,event)}"
                              update="applyToId"&gt;&lt;/p:ajax&gt; 
      &lt;/p:selectCheckboxMenu&gt;&lt;/p:column&gt;
  </code></pre>
  
  <p>The controller method:</p>
  
  <pre><code>public void populateLabel(NewRules rule,AjaxBehaviorEvent event) {
      if (rule.getAccountTypes().length == 0) {
          rule.setAccountTypeLabel("Select One"); 
      } else {
           rule.setAccountTypeLabel("Edit"); 
      }}
  </code></pre>
  
  <p>I am not sure if I am doing something wrong. Thanks in advance.</p>