CellTable - How to temporarily bypass AsyncDataProvider?

60 views
Skip to first unread message

Magnus

unread,
Nov 16, 2012, 4:54:17 PM11/16/12
to google-we...@googlegroups.com
Hello,

I have a small chat within my chess application. The chat messages are displayed within a CellTable, which has a Pager and an AsyncDataProvider. The data provider fetches the messages from the server and pushes them into the CellTable via the onRangeChange method. So far, so good.

When the user enters a message, it is sent to the server and the whole table is reloaded by calling setVisibleRangeAndClearData. This is, what I want to change. Instead of reloading the whole table, I would like to just append the new message to the table. I managed to do this as follows:

  int n = tbl.getRowCount();
  pvd.updateRowData (n,lst);
  pvd.updateRowCount(n+1, true);
  gotoLastPage(); // !!!
  scp.scrollToBottom();

The problem is that the new message may be beyond the currend page size. I want that after the append the last message is visible. But whatever I do to change the page start ("!!!" above), there is always the data provider invoked which makes a call to the server.

How can I - just in this situation - update the table without reloading it?
Is there a simple solution?

Thanks
Magnus

Magnus

unread,
Nov 21, 2012, 11:37:05 AM11/21/12
to google-we...@googlegroups.com
Hi,

maybe it's not a good idea to "bypass" the AsyncDataProvider, as proposed above.
But perhaps someone can give a useful hint when describing the problem in another way:

There are two different use cases, where the CellTable is filled with data:

1. Using the Pager
When selecting "next page", "previous page" and so on, the "onRangeChanged" method is called, which in turn fetches the rows from the server.

2. Entering a Chat Message
When the user enters a message, the server should not be called. We already know the new message on the client side. The CellTable should just be extended with the new row. The page size doesn't matter, if it's simpler then...

Hoping for hints...

Magnus

Matthew Dempsky

unread,
Nov 21, 2012, 12:43:05 PM11/21/12
to google-web-toolkit
On Wed, Nov 21, 2012 at 8:37 AM, Magnus <alpine...@googlemail.com> wrote:
maybe it's not a good idea to "bypass" the AsyncDataProvider, as proposed above.

What about modifying your AsyncDataProvider to allow the client-side to stuff new data in directly?

Magnus

unread,
Nov 22, 2012, 10:20:56 PM11/22/12
to google-we...@googlegroups.com
Hi Matthew,

you're right, this must be the way to do it.

At the moment, data from the server is pushed into the CellTable by calling AsyncDataProvider.updateRowData.
The problem is that I don't know exactly what it does. The docs only say "Inform the displays of the new data." But I have not seen the concept of these "displays" somewhere.

I also don't know exactly how to tell within the body of the data provider's onRangeChanged method which rows (indices) are the new ones.

In addition: What about the page size? When appending new rows the page size may be exceeded. What should we do in this case? Increase the starting position of the current page?
Remember, it's a chat. It would  be ok if the page size stays constant and the first row disappears when a new row is appended...

A code skeleton would be fine...

Magnus
Reply all
Reply to author
Forward
0 new messages