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
HasValue<User>orHasValue<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:
For a
PagingScrollTable, aMutableTableModel<RowType>is used as implementation ofTableModel<RowType>.MutableTableModel<RowType>in turn implements the following interfaces:HasRowCountChangeHandlers,HasRowInsertionHandlers,HasRowRemovalHandlers,HasRowValueChangeHandlers<RowType>The
PagingScrollTableregisters itself as listener on theMutableTableModeland therefore gets very fine-grained notifications of updates. The resulting implementation should be very performant.