GWT MVP with a table

gwt, mvp

Solution

`HasValue<User>` or `HasValue<TableRow>` would not work in this case, because this would only permit handling a single row. You could maybe use a `HasValue<List<User>>` but that would mean, that your view has to render the entire table on each change.

I might be wrong, but I think for tables its best to use a Supervising Presenter instead of the Passive View. Have a look at the PagingScrollTable widget in the GWT Incubator:

public class PagingScrollTable<RowType> extends AbstractScrollTable implements
    HasTableDefinition<RowType>, ... {
  ...
  TableModel<RowType> getTableModel() 
  ...
}

For a `PagingScrollTable`, a `MutableTableModel<RowType>` is used as implementation of `TableModel<RowType>`.

`MutableTableModel<RowType>` in turn implements the following interfaces:

`HasRowCountChangeHandlers`, `HasRowInsertionHandlers`, `HasRowRemovalHandlers`, `HasRowValueChangeHandlers<RowType>`

The `PagingScrollTable` registers itself as listener on the `MutableTableModel` and therefore gets very fine-grained notifications of updates. The resulting implementation should be very performant.

Problem

When working with MVP in GWT how would you work with a table? For example if you had a table of users does your view look like this? ``` public interface MyDisplay{ HasValue<User> users(); } ``` or would it be more like this? ``` public interface MyDisplay{ HasValue<TableRow> rows(); } ``` MVP makes a ton of sense until you start dealing with widgets that need to display lists of non-primitive data. Can anybody shed some light? This mailing list archive appears to ask the same question but never reaches a solid resolution... http://www.mail-archive.com/google-web-toolkit@googlegroups.com/msg24546.html

Original source