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 224 other followers

  • Sleepless Nights…

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

    • 1,034,589 hits

Archive for March 2nd, 2011

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);

Posted in Google Web Toolkit | 10 Comments »

%d bloggers like this: