Monday, October 29, 2012

Re: Catch-22 with Celltable and AsyncDataProvider

I would not consider this a 'flaw': there is no problem in setting the row count asynchronously, way after having finished initialization. In fact, it is not even possible for the method to 'wait until the value is returned': this is the very point of asynchronous loading. The RPC call may look like the following:
ContactsService.Util.getInstance().getCount(
new AsyncCallback<Integer>() {
@Override
public void onSuccess(Integer result) {
table.setRowCount(result, true);
}
@Override
public void onFailure(Throwable caught) {
Window.alert("error: "+caught);
}
});
The user may notice a short period of time while the table pager shows something like '1-1 of 0' before the row count RPC call returns.

Regards,
--

On Saturday, May 5, 2012 5:43:42 PM UTC+2, Mike Dee wrote:
According to the Celltable Developers Guide here:


The example given for AsyncDataProvider seems to have a flaw here when setting the row count.

// Add the columns.
table.addColumn(nameColumn, "Name");
table.addColumn(addressColumn, "Address");

// Set the total row count. You might send an RPC request to determine the total row count.
table.setRowCount(CONTACTS.size(), true); 

// Set the range to display. In this case, our visible range is smaller than the data set.
table.setVisibleRange(0, 3);

As the comment suggests, an RPC call would likely be necessary and it would likely be asynchronous.

That leaves the question, how does one know that the RPC call will return with the size by the time it is needed/used later on?  Should method wait until the value is returned?


 

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

No comments:

Post a Comment