title: 'Show All' button for Primefaces DataTable
body: <p>I would like to have a 'Show All' button for a primefaces datatable, however, I'm experiencing some trouble. Here's some test code that demostrates the problem:</p>
  
  <p>Test.xhtml:</p>
  
  <pre><code>          ...  
              &lt;h:form&gt;
                  &lt;p:selectBooleanCheckbox value="#{testBean.showAll}" itemLabel="Show All"&gt;
                      &lt;p:ajax update="@form"/&gt; 
                  &lt;/p:selectBooleanCheckbox&gt;
  
                  &lt;p:panel id="test"&gt;
                      &lt;p:dataTable id="values" var="value" value="#{testBean.fullList}" filteredValue="#{testBean.filteredList}" paginatorAlwaysVisible="false" 
                                   paginator="#{!testBean.showAll}" rows="#{!testBean.showAll ? 2 : null }" widgetVar="valuesTable"
                                   emptyMessage="No records found."&gt;
  
  
                          &lt;p:column id="enum" sortBy="#{value.toString()}" filterBy="#{value.toString()}" filterMatchMode="contains"&gt;
                              &lt;f:facet name="header"&gt;
                                  &lt;h:outputText value="Enum" /&gt;
                              &lt;/f:facet&gt;
                              &lt;h:outputText value ="#{value.toString()}"/&gt;
                          &lt;/p:column&gt;
                          &lt;p:column id="name" sortBy="#{value.name}"  filterBy="#{value.name}" filterMatchMode="contains"&gt;
                              &lt;f:facet name="header"&gt;
                                  &lt;h:outputText value="Name" /&gt;
                              &lt;/f:facet&gt;
                              &lt;h:outputText value="#{value.name}" /&gt;
                          &lt;/p:column&gt;
                      &lt;/p:dataTable&gt;
                  &lt;/p:panel&gt;
              &lt;/h:form&gt;
            ...
  </code></pre>
  
  <p>And here's TestBean.java:</p>
  
  <pre><code>import javax.inject.Named;
  import javax.enterprise.context.SessionScoped;
  import java.io.Serializable;
  import java.util.Arrays;
  import java.util.List;
  
  @Named(value = "testBean")
  @SessionScoped
  public class TestBean implements Serializable {
  
      public static enum Value {
  
          ONE, TWO, THREE;
  
          public String getName() {
              return name().toLowerCase();
          }
  
          @Override
          public String toString() {
              return this.name();
          }
      }
  
      /**
       * Creates a new instance of TestBean
       */
      public TestBean() {
      }
  
      private boolean showAll = false;
      private List&lt;Value&gt; fullList = Arrays.asList(Value.values());
      private List&lt;Value&gt; filteredList;
  
      public boolean isShowAll() {
          return showAll;
      }
  
      public void setShowAll(boolean showAll) {
          this.showAll = showAll;
      }
  
      public List&lt;Value&gt; getFullList() {
          return fullList;
      }
  
      public void setFullList(List&lt;Value&gt; fullList) {
          this.fullList = fullList;
      }
  
      public List&lt;Value&gt; getFilteredList() {
          return filteredList;
      }
  
      public void setFilteredList(List&lt;Value&gt; filteredList) {
          this.filteredList = filteredList;
      }
  
  }
  </code></pre>
  
  <p>If I don't change tabs, the page works as expected: toggling the 'Show All' button updates the table to show all 3 values, or only two. However, if show all is not checked (only 2 rows are showing), and I click to the 2nd page of the table to view the third record, and then click 'Show All', the table does not update properly. It removes the paginator from the top of the table (as expected), but still only shows the 3rd record. And if I then uncheck show all and navigate back to the first page of the datatable, it is now broken too.</p>
  
  <p>I've tried changing the ajax update statement to the id of the table, but that didn't change the results.</p>
  
  <p>Am I doing something wrong? Thanks in advance.</p>