David Chandler's Journal of Java Web and Mobile Development

  • David M. Chandler

    Web app developer since 1994 and Google Cloud Platform Instructor now residing in Colorado. Besides tech, I enjoy landscape photography and share my work at ColoradoPhoto.gallery.

  • Subscribe

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 223 other followers

  • Sleepless Nights…

    March 2011
    S M T W T F S
  • Blog Stats

    • 1,033,720 hits

GWT 2.2 AsyncDataProvider / CellTable gotcha

Posted by David Chandler on March 2, 2011

I’ve been trying out CellTable in GWT 2.2 and found a potential gotcha. I created an AsyncDataProvider and attached the CellTable to it, but found that the table does not refresh properly unless you update BOTH row count and row data. If you call only updateRowData(), the CellTable will show the loading bar when there are zero rows, and will not remove rows when you delete them in the provider. The solution is simple: whenever you want to update a CellTable bound to an AsyncDataProvider, be sure to call both updateRowData() and updateRowCount(). Example code here:

	public static class ListDataProvider extends
		private Logger logger = Logger
		private ListwidgetRequestFactory rf;

		public ListDataProvider(ListwidgetRequestFactory requestFactory)
			this.rf = requestFactory;

		protected void onRangeChanged(HasData<ItemListProxy> display)
		private void getData()
			logger.warning("getting data");
			// To retrieve relations and value types, use .with()
			Request<List<ItemListProxy>> findAllReq = rf.itemListRequest()
			// Receiver specifies return type
			findAllReq.fire(new Receiver<List<ItemListProxy>>()
				public void onSuccess(List<ItemListProxy> response)
					updateRowCount(response.size(), true);
					updateRowData(0, response);

10 Responses to “GWT 2.2 AsyncDataProvider / CellTable gotcha”

  1. tarek said


    I have the same problem with the table. Everything worked fine before i switched to the RequestFactory pattern. I used the Service/ServiceAsync pattern. Your fixed didnt worked for me. How do you attach the AsyncDataProvider to the table? Perhaps i make a fault there.


  2. sowdri said

    hi David,

    In the existing implementation of AysncDataProvider, even when the back button is pressed, we have to fetch the data from the server.

    Will it be better to have a data structure List which will store the list of items already fetched from the server, such that we need not hit the server on hitting back button??


  3. Hello,

    I was updating the SimplePager pageSize *after* updating the AsyncDataProvider rowcount and rowdata and my cell table was not displaying any data (just showing the loading bar)

    I fixed this by updating the SimplePager before everything else.

    So, if you need to update the SimplePager pageStart in your code, then the order that works for me now is:

  4. still valid in 2.4

  5. hi i have a refresh button on my UI. so that wen i click it, table gets refreshed weather there is any addition or deletion of any row in database.

  6. Anders K said

    Also the issue in CellTree in GWT 2.5..

  7. shashwat said

    will this thing work in GWT 2.3 …and if you have a complete code please paste here..
    My problem is ..I need to add a empty row in the cell table without repainting the celltable

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: