private int getRowsToBeRendered() {
    if (isDataLoaded()) {
      if (dataProvider.getCurrentPage() == 0) {
        dataProvider.nextPage();
      }

      return dataProvider.getCurrentPageSize();
    }

    return 0;
  }
  protected void render(boolean refresh) {
    if (refresh) {
      clear();
    }
    int rowCount = getRowsToBeRendered();

    for (int i = 0; i < rowCount; i++) {
      T value = dataProvider.get();
      if (value == null) {
        throw new DataProviderExcpetion("Index error = " + i);
      }
      renderer.render(value);
      if (dataProvider.hasNext()) {
        dataProvider.next();
      } else {
        break;
      }
    }
    updatePager();
  }
  public void reset(boolean reloadData) {
    if (dataProvider != null) {
      dataProvider.reset();
    }

    if (pager != null) {
      pager.update(0, true);
    }

    if (reloadData) {
      loadData();
    }
  }
  protected void onTransactionCompleted(boolean commited) {
    final int pageStartRecordOnTransactionEnd = dataProvider.getCurrentPageStartRecord();
    transactionRunning = false;
    updatePagerState();

    Scheduler.get()
        .scheduleDeferred(
            new ScheduledCommand() {
              @Override
              public void execute() {
                refreshPage(pageStartRecordOnTransactionEnd);
              }
            });
  }
 public void setPageSize(int pageSize) {
   this.pageSize = pageSize;
   if (dataProvider != null) {
     dataProvider.setPageSize(pageSize);
   }
 }
 protected void updatePager() {
   if (isDataLoaded() && pager != null) {
     pager.update(dataProvider.getCurrentPage(), !dataProvider.hasNextPage());
   }
 }
 protected void refresh(boolean clearPreviousData) {
   dataProvider.firstOnPage();
   render(clearPreviousData);
 }
 public boolean isDirty() {
   return dataProvider != null && dataProvider.isDirty();
 }
 public boolean isDataLoaded() {
   return dataProvider != null && dataProvider.isLoaded();
 }
 public void rollback() {
   if (dataProvider != null) {
     dataProvider.rollback();
   }
 }
 public void commit() {
   if (dataProvider != null) {
     dataProvider.commit();
   }
 }
 public int indexOf(T object) {
   if (dataProvider != null) {
     return dataProvider.indexOf(object);
   }
   return -1;
 }
 public void set(int index, T object) {
   if (dataProvider != null) {
     dataProvider.set(index, object);
   }
 }
 public void remove(int index) {
   if (dataProvider != null) {
     dataProvider.remove(index);
   }
 }
 public void add(T object) {
   if (dataProvider != null) {
     dataProvider.add(object);
   }
 }
 @Override
 public void nextPage() {
   if (isDataLoaded()) {
     dataProvider.nextPage();
   }
 }
 @Override
 public void previousPage() {
   if (isDataLoaded()) {
     dataProvider.previousPage();
   }
 }
 public void loadData() {
   if (dataProvider != null) {
     dataProvider.load();
   }
 }