Paging a simple CellTable freezes

247 views
Skip to first unread message

Nick Newman

unread,
Nov 11, 2010, 2:13:48 PM11/11/10
to Google Web Toolkit
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);
}
}

stefannMeisner

unread,
Nov 15, 2010, 11:47:34 AM11/15/10
to Google Web Toolkit
Hi

I Am experiencing the same problem. I have tried to setup a simple MVP
application. When I get the "bar with the moving bands" I press a link
that
goes to the same page. The updated page shows the CellTable with the
correct
lines visible.

Any help appreciated. A working example with CellTable and SimplePager
would
be nice! The documentation seems to be outdated on this subject.

Regards,
Stefan

John LaBanca

unread,
Nov 16, 2010, 11:58:44 AM11/16/10
to google-we...@googlegroups.com
Put your list in a ListDataProvider and set the cellTable as the display:
ListDataProvider<Contact> dataProvider = new ListDataProvider<Contact>(CONTACTS);
dataProvider.addDataDisplay(cellTable);

When you change the visible range of a CellTable, it clears its current data and fires a RangeChangeEvent.  Something (like a ListDataProvider) has to be listening for the event and provide more data.  In your case, you are pushing the initial data, but the CellTable is only retaining the data on the current page.  When you change the page, the CellTable is waiting for a data provider to push more data into it.

Thanks,
John LaBanca
jlab...@google.com


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


Nick Newman

unread,
Nov 16, 2010, 12:15:31 PM11/16/10
to google-we...@googlegroups.com
Thank you so much!  I knew it had to be something simple.

Nick

Stefan Meisner Larsen

unread,
Nov 17, 2010, 2:18:03 PM11/17/10
to google-we...@googlegroups.com
Thanks a lot, John!

2010/11/16 John LaBanca <jlab...@google.com>
Reply all
Reply to author
Forward
0 new messages