title: PrimeFaces selectCheckboxMenu: Old values in toggleSelect actionListener
body: <p>In my JSF view I have a <code>p:selectCheckboxMenu</code> where I want to perform some business logic via AJAX on the selected values.</p>
  
  <p>For a simple <code>change</code> event it works fine, but for a <code>toggleSelect</code> event not. Inside my listener method I am retrieving the old selection, but I am expecting the new selection here.</p>
  
  <p>See the following example:</p>
  
  <pre><code>@ViewScoped
  @Named
  public class RequestBean implements Serializable {
      private List&lt;String&gt; list; // + getter/setter
  
      @PostConstruct
      private void init() {       
          list = new ArrayList&lt;String&gt;() {{
            add("one");  add("two"); add("three");
          }};
      }
  
      public void listener() {
          System.out.println("Current content of \"list\":");
          for(String s : list) {
              System.out.println(s);
          }
      }
  }
  </code></pre>
  
  <p>in JSF view:</p>
  
  <pre><code>&lt;p:selectCheckboxMenu value="#{requestBean.list}" label="List"&gt;
      &lt;f:selectItem itemValue="one" itemLabel="one"/&gt;
      &lt;f:selectItem itemValue="two" itemLabel="two"/&gt;
      &lt;f:selectItem itemValue="three" itemLabel="three"/&gt;
      &lt;p:ajax event="toggleSelect" listener="#{requestBean.listener}"  /&gt;
      &lt;p:ajax event="change" listener="#{requestBean.listener}" /&gt;
  &lt;/p:selectCheckboxMenu&gt;
  </code></pre>
  
  <p>Now lets consider the following use-case: You are entering the view, "one" and "two" are selected. If I click the "select all" checkbox, the outcome is:</p>
  
  <pre><code>Info:   Current content of "list":
  Info:   one
  Info:   two
  </code></pre>
  
  <p>But the expected outcome would look like this:</p>
  
  <pre><code>Info:   Current content of "list":
  Info:   one
  Info:   two
  Info:   three
  </code></pre>
  
  <p>For the regular change event it works as expected. Here I am getting the new selection inside the listener. How may I fix it? Or what am I doing wrong? </p>
  
  <hr>
  
  <blockquote>
    <p>GlassFish 4.1, running on Java 1.8.0_45</p>
    
    <p>JSF 2.2.10 (Mojarra)</p>
    
    <p>PrimeFaces 5.1</p>
    
    <p>OmniFaces 1.8.1</p>
  </blockquote>