Hi,
I'm trying the CellTable from GWT 2.1 and I must be doing something
silly because I cannot get it to page. When I display the table I see
the first page just fine, but when I press the page-forward button I
get a "busy" indication (a bar with moving bands) and that stays there
forever.
Could some kind soul take a look at the following sample code (copied
from an example with minor changes) to see what I'm doing wrong.
Thanks,
Nick
public class MyModule implements EntryPoint
{
/**
* A simple data type that represents a contact.
*/
static class Contact
{
private final String address;
private final Date birthday;
private final String name;
public Contact(String name, Date birthday, String address)
{
this.name = name;
this.birthday = birthday;
this.address = address;
}
}
public void onModuleLoad()
{
/**
* The list of data to display.
*/
List<Contact> CONTACTS = new ArrayList<Contact>();
List<Contact> sample = Arrays.asList( //
new Contact("John", new Date(80, 4, 12), "123 Fourth
Avenue"), //
new Contact("Joe", new Date(85, 2, 22), "22 Lance
Ln"), //
new Contact("George", new Date(46, 6, 6), "1600
Pennsylvania Avenue"));
// Make lots of entries
for (int i = 0; i < 50; ++i)
CONTACTS.addAll(sample);
// Create a CellTable.
CellTable<Contact> table = new CellTable<Contact>();
table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
// Add a text column to show the name.
TextColumn<Contact> nameColumn = new TextColumn<Contact>()
{
@Override
public String getValue(Contact object)
{
return
object.name;
}
};
table.addColumn(nameColumn, "Name");
// Set the total row count. This isn't strictly necessary, but
it affects
// paging calculations, so its good habit to keep the row
count up to date.
table.setRowCount(CONTACTS.size(), true);
// Push the data into the widget.
table.setRowData(0, CONTACTS);
/*
* Add a pager
*/
SimplePager.Resources pagerResources =
GWT.create(SimplePager.Resources.class);
SimplePager pager = new SimplePager(TextLocation.CENTER,
pagerResources, false, 0, true);
pager.setDisplay(table);
VerticalPanel resultPanel = new VerticalPanel();
resultPanel.add(pager);
resultPanel.add(table);
RootPanel.get("gwt").add(resultPanel);
}
}