title: Lazy Loading + Command Button on Primefaces
body: <p>I'm newbie on JSF and I'm working with primefaces-2.2.RC2.
  I have a commandButton and when I click I want that it fill a dataTable that use lazyLoading (my work is based on primefaces showcase).
  When I click on commandButton, the data is not loaded.</p>
  
  <p>Here piece of my code:</p>
  
  <pre><code>&lt;p:commandButton value="Search"
                action="#{tableBean.search()}"
                update="carList"
                                       /&gt;
  &lt;p:dataTable id="carList" 
               var="car" 
               value="#{tableBean.lazyDataModel}" 
               paginator="true" 
               rows="10"
               dynamic="true" 
               lazy="true" 
               paginatorPosition="bottom"
               &gt;
  </code></pre>
  
  <p>Ande on my bean:</p>
  
  <pre><code>@ViewScoped
  public class TableBean {
      LazyDataModel&lt;Car&gt; lazyDataModel;
      public TableBean() {
          lazyDataModel = new LazyDataModel&lt;Car&gt;() {
              @Override
              public List&lt;Car&gt; load(int i, int i1, String string, boolean bln, Map&lt;String, String&gt; map) {
                  return new ArrayList&lt;Car&gt;();
              }
          };
      }
  
      public LazyDataModel&lt;Car&gt; getLazyDataModel() {
           return lazyDataModel;
      }
  
      public void search() {
          lazyDataModel = new LazyDataModel&lt;Car&gt;() {
              @Override
              public List&lt;Car&gt; load(int first, int pageSize, String sortField,boolean sortOrder, Map&lt;String, String&gt; filters) {
                  return fetchLazyData(first, pageSize);
              }
  
              @Override
              public void setRowIndex(int rowIndex) {                
                  setPageSize(10);
                  if (rowIndex == -1 || getPageSize() == 0) {
                     super.setRowIndex(-1);
                  } else {
                     super.setRowIndex(rowIndex % getPageSize());
                  }
              }
  
              public List&lt;Car&gt; fetchLazyData(int first, int pageSize) {
                   System.out.println("Loading the lazy car data between " + first + " and " + (first + pageSize));
              List&lt;Car&gt; lazyCars = new ArrayList&lt;Car&gt;();
  
                   for (int i = 0; i &lt; pageSize; i++) {
                       int offset = i + first;
                       lazyCars.add(new Car("Model_" + offset, (int) (Math.random() * 60 + 1960), "Brand_" + offset, "Color_" + offset));
                   }
                   return lazyCars;
              }
         };
         lazyDataModel.setRowCount(10000);
      }
  }
  </code></pre>
  
  <hr>
  
  <p>update: I descovered that I have to bind my DataTable and on my bean I have to call loadLazyData() function.</p>