GWT MVP with a table

When working with MVP in GWT, how will you work with the table? For example, if you have a user table, does your view look like this?

public interface MyDisplay{ HasValue<User> users(); } 

or will it be more like?

 public interface MyDisplay{ HasValue<TableRow> rows(); } 

MVP makes a ton until you begin to deal with widgets that need to display lists of non-primitive data. Can anyone shed some light?

This mailing list archive seems to ask the same question, but never reaches a solid resolution ...

http://www.mail-archive.com/ google-web-toolkit@googlegroups.com /msg24546.html

+6
mvp gwt
source share
3 answers

HasValue<User> or HasValue<TableRow> will not work in this case, because it will allow processing of only one line. Perhaps you can use HasValue<List<User>> , but that would mean that your view should display the whole table with every change.

I may be mistaken, but I find it better to use the Supervising Presenter for tables instead of Passive browsing . Take a look at the PagingScrollTable widget in the GWT Incubator :

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

When a PagingScrollTable a MutableTableModel<RowType> used as an implementation of TableModel<RowType> .

MutableTableModel<RowType> in turn implements the following interfaces:

HasRowCountChangeHandlers , HasRowInsertionHandlers , HasRowRemovalHandlers , HasRowValueChangeHandlers<RowType>

PagingScrollTable registers as a listener on the MutableTableModel and therefore receives very small update notifications. The resulting implementation must be very efficient.

+6
source share
+2
source share

This could be a very interesting blog post:

http://www.draconianoverlord.com/2010/03/31/gwt-mvp-tables.html

+2
source share

All Articles