AsyncDataProvider (GWT Javadoc)

Overview | Package | Class | Use | Deprecated | Help
| GWT 2.7.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.gwt.view.client
Class AsyncDataProvider<T>

    java.lang.Object
      com.google.gwt.view.client.AbstractDataProvider<T>
          com.google.gwt.view.client.AsyncDataProvider<T>

Type Parameters:
  `T` - the data type of records in the list

All Implemented Interfaces:
  ProvidesKey<T>

    public abstract class AsyncDataProvider<T>

extends AbstractDataProvider<T>

An implementation of `AbstractDataProvider` that allows the data to be modified.

### Example

>     public class AsyncDataProviderExample implements EntryPoint {

>       /**
>        * A custom {@link AsyncDataProvider}.
>        */
>       private static class MyDataProvider extends AsyncDataProvider<String> {
>         /**
>          * {@link #onRangeChanged(HasData)} is called when the table requests a new
>          * range of data. You can push data back to the displays using
>          * {@link #updateRowData(int, List)}.
>          */
>         @Override
>         protected void onRangeChanged(HasData<String> display) {
>           // Get the new range.
>           final Range range = display.getVisibleRange();

>           /*
>            * Query the data asynchronously. If you are using a database, you can
>            * make an RPC call here. We'll use a Timer to simulate a delay.
>            */
>           new Timer() {
>             @Override
>             public void run() {
>               // We are creating fake data. Normally, the data will come from a
>               // server.
>               int start = range.getStart();
>               int length = range.getLength();
>               List<String> newData = new ArrayList<String>();
>               for (int i = start; i < start + length; i++) {
>                 newData.add("Item " + i);
>               }

>               // Push the data to the displays. AsyncDataProvider will only update
>               // displays that are within range of the data.
>               updateRowData(start, newData);
>             }
>           }.schedule(3000);
>         }
>       }

>       public void onModuleLoad() {
>         // Create a CellList.
>         CellList<String> cellList = new CellList<String>(new TextCell());

>         // Create a data provider.
>         MyDataProvider dataProvider = new MyDataProvider();

>         // Add the cellList to the dataProvider.
>         dataProvider.addDataDisplay(cellList);

>         // Create paging controls.
>         SimplePager pager = new SimplePager();
>         pager.setDisplay(cellList);

>         // Add the widgets to the root panel.
>         VerticalPanel vPanel = new VerticalPanel();
>         vPanel.add(pager);
>         vPanel.add(cellList);
>         RootPanel.get().add(vPanel);
>       }
>     }

Constructor Summary
`protected` | `AsyncDataProvider()` Constructs an AsyncDataProvider without a key provider.
`protected` | `AsyncDataProvider(ProvidesKey<T> keyProvider)` Constructs an AsyncDataProvider with the given key provider.

Method Summary
`void` | `updateRowCount(int size, boolean exact)` Inform the displays of the total number of items that are available.
`void` | `updateRowData(int start, java.util.List<T> values)` Inform the displays of the new data.

Methods inherited from class com.google.gwt.view.client.AbstractDataProvider
`addDataDisplay, getDataDisplays, getKey, getKeyProvider, getRanges, onRangeChanged, removeDataDisplay, updateRowData`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AsyncDataProvider

    protected AsyncDataProvider()

  Constructs an AsyncDataProvider without a key provider.

### AsyncDataProvider

    protected AsyncDataProvider(ProvidesKey<T> keyProvider)

  Constructs an AsyncDataProvider with the given key provider.

  Parameters:
    `keyProvider` - an instance of ProvidesKey, or null if the record object should act as its own key

Method Detail

### updateRowCount

    public void updateRowCount(int size,
                               boolean exact)

  Description copied from class: `AbstractDataProvider`
  Inform the displays of the total number of items that are available.

  Overrides:
    `updateRowCount` in class `AbstractDataProvider<T>`
  Parameters:
    `size` - the new total row count
    `exact` - true if the count is exact, false if it is an estimate

### updateRowData

    public void updateRowData(int start,
                              java.util.List<T> values)

  Description copied from class: `AbstractDataProvider`
  Inform the displays of the new data.

  Overrides:
    `updateRowData` in class `AbstractDataProvider<T>`
  Parameters:
    `start` - the start index
    `values` - the data values

Overview | Package | Class | Use | Deprecated | Help
| GWT 2.7.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD