if(collection == null) {
callback.onSuccess(null);
return;
}
AsyncCallbackGroup group = new AsyncCallbackGroup("Load offset="+offset+" limit="+limit);
collection.getLength(new AsyncCallbackGroupMember<Integer>(group) {
@Override
public void onSuccess(Integer length) {
totalItems = (length == null?-1:length);
super.onSuccess(null);
}
@Override
public void onFailure(Throwable caught) {
totalItems = -1;
super.onFailure(caught);
}
});
collection.load(offset, limit, new AsyncCallbackGroupMember<T[]>(group, getClass().getName()+".collection.load()") {
@Override
public void onSuccess(T[] models) {
//GWT.log("Loading list ... got "+models.length+" results attached = "+isAttached(), null);
showLoadedModels(models, offset, limit, group);
super.onSuccess(null);
}
});
group.ready(callback);
}