Simple CellList example 2.1 M3

40 views
Skip to first unread message

nogridbag

unread,
Sep 24, 2010, 2:46:19 PM9/24/10
to Google Web Toolkit
Are there any CellList or CellTable examples using GWT 2.1 M3? Of the
few examples I can find, they are all out dated. A simple hello world
example will suffice.

Looking at old examples and google IO talks, they use ListViewAdapter
which appears to be replaced with ListDataProvider. I'm confused what
role ListDataProvider plays and how it works in conjunction with the
Cell widgets.

Bayard Randel

unread,
Sep 26, 2010, 6:17:39 PM9/26/10
to Google Web Toolkit
I certainly know how you feel - I'd love to see some documentation for
2.1 as well. I'm sure the gwt team is diligently working on it as we
speak.

Here's some code that I just wrote, that hopefully will help. I'm
passing my ListDataProvider from my presenter into my view.. I'm still
uncertain if this is the best approach.

Presenter
---------

private void updateTable(List<Listing> result) {
ListDataProvider<Listing> listingDataProvider = new
ListDataProvider<Listing>(result);

getView().renderListingTable(listingDataProvider);
}

View
-----
public void renderListingTable(ListDataProvider<Listing> provider) {
CellTable<Listing> ListingCellTable = new CellTable<Listing>();

ListingPanel.add(ListingCellTable);
ListingCellTable.setTitle("Current Listings");
ListingCellTable.setHeight("300px");

Column<Listing, String> nameColumn =
new Column<Listing, String>(new TextCell()) {
@Override
public String getValue(Listing object) {
return object.getItemName();
}
};

Column<Listing, String> ListingStatusColumn =
new Column<Listing, String>(new TextCell()) {
@Override
public String getValue(Listing object) {
return object.getStatus().toString();
}
};

ListingCellTable.addColumn(nameColumn, "Listing");
ListingCellTable.addColumn(ListingStatusColumn, "Status");

provider.addDataDisplay(ListingCellTable);
}
Reply all
Reply to author
Forward
0 new messages