Hey,
I was playing around with incubator's PagingScrollTable for a while,
and I've come across an issue there. I have a DataSourceTableModel
that extends MutableTableModel, and looks like this:
public class DataSourceTableModel extends MutableTableModel {
...
@Override
public void requestRows(final TableModelHelper.Request request,
final Callback callback) {
UserService.App.getInstance().getUsers(new
AsyncCallback<ViewResult<User>>() {
@Override
public void onFailure(Throwable throwable) {
Window.alert("failed retrieving the users" +
throwable);
}
@Override
public void onSuccess(final ViewResult<User>
userViewResult) {
Window.alert("received rows: " +
userViewResult.getTotalRows());
// Application.cachedTableModel.setRowCount
(userViewResult.getTotalRows());
callback.onRowsReady(request, new
TableModelHelper.Response() {
@Override
public Iterator getRowValues() {
final Iterator<ValueRow<User>> rows =
userViewResult.getRows().iterator();
return new Iterator(){
@Override
public boolean hasNext() {
return rows.hasNext();
}
@Override
public Object next() {
return rows.next().getValue();
}
@Override
public void remove() {
}
};
}
});
}
});
}
}
It is then wrapped around in a CachedTableModel:
CachedTableModel<User> cachedTableModel = new CachedTableModel<User>
(tableModel);
Now, cachedTableModel actually holds a reference to the
DataSourceTableModel. When retrieving the data using
DataSourceTableModel.requestRows(,,,) method, I get back a number of
total rows in the result set, and would like to update the paging
control accordingly. The problem is, if I invoke setRowCount
(userViewResult.getTotalRows())) in this method,it only updates the
underlying DataSourceTableModel, not the cachedTableModel, which is
actually used by the PagingScrollTable.
A RowCountChangeEvent event is fired when invoking setRowCount() on a
DataSourceTableModel, but I can't register a listener on
CachedTableModel for it, because CachedTableModel.setRowCount() looks
like
public void setRowCount(int rowCount) {
tableModel.setRowCount(rowCount);
super.setRowCount(rowCount);
}
so it would in turn invoke DataSourceTableModel's setRowCount, and go
into an infinite loop, as it fires another event.
Am I missing something here? Are there any other ways to achieve this
functionality without holding a back reference to a CachedTableModel
inside a DataSourceTableModel?
regards,
Andrius Juozapaitis
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---