0

I am beginner in GWT application development. I have searched about CellTable online. Didn't got any explaination other than some examples.

Now I really want to know what exactly the DataProvider does in CellTable? Also would like know more about celltable and if there are any resources available for the same??

Pradip Borde
  • 2,516
  • 4
  • 18
  • 20

1 Answers1

5

The dataprovider holds your model. Whenever you change your model (for instance, a list of object mapped to your cellTable), it will be in charge of updating the display.

It acts as a controller between your display (the cellTable) and the model (i.e. a list of objects, typically a list of shared objects coming from your back-end).

Here is an example with a listdataprovider:

@UiField(provided = true)
protected CellTable<TableRowDataShared> cellTable;

protected ListDataProvider<TableRowDataShared> dataProvider = new ListDataProvider<TableRowDataShared>();

public void init() {
    dataProvider.addDataDisplay(cellTable);
    // init your cellTable here...
}

public void onModelUpdate(List<TableRowDataShared> newData) {
    dataProvider.getList().clear();
    dataProvider.getList().addAll(newData);
    dataProvider.flush();
    dataProvider.refresh();
    cellTable.redraw();
}
Olivier Tonglet
  • 3,312
  • 24
  • 40
  • Pretty clear. But is it necessary to use DataProvider while implementing pagination using SimplePager?? – Pradip Borde Aug 06 '13 at 08:10
  • Good question... If you are using a cellTable you should use a data provider. If you are using a cellList or something else you could set up your own data providing implementation. Will the SimplePager work then ? I guess so since data providing and pagination are separated tasks. While using pagination you are just displaying different portion of your data but the data stay the same isn't it? From this section http://www.gwtproject.org/doc/latest/DevGuideUiCellWidgets.html#Selection_Data_Paging – Olivier Tonglet Aug 07 '13 at 07:15