在GWT中使用MVP时,如何使用表?例如,如果您有一个用户表,您的视图是这样的吗?
public interface MyDisplay{
HasValue<User> users();
}
Run Code Online (Sandbox Code Playgroud)
还是会更像这样?
public interface MyDisplay{
HasValue<TableRow> rows();
}
Run Code Online (Sandbox Code Playgroud)
在你开始处理需要显示非原始数据列表的小部件之前,MVP很有意义.任何人都能解释一下吗?
这个邮件列表存档似乎提出了同样的问题,但从未达成可靠的解决方案......
http://www.mail-archive.com/google-web-toolkit@googlegroups.com/msg24546.html
HasValue<User>或者HasValue<TableRow>在这种情况下不起作用,因为这只允许处理一行.您可以使用a HasValue<List<User>>但这意味着,您的视图必须在每次更改时呈现整个表.
我可能错了,但我认为桌子最好使用监督演示者而不是被动视图.看看GWT Incubator中的PagingScrollTable小部件:
public class PagingScrollTable<RowType> extends AbstractScrollTable implements
HasTableDefinition<RowType>, ... {
...
TableModel<RowType> getTableModel()
...
}
Run Code Online (Sandbox Code Playgroud)
对于a PagingScrollTable,a MutableTableModel<RowType>用作实现TableModel<RowType>.
MutableTableModel<RowType> 反过来实现以下接口:
HasRowCountChangeHandlers,HasRowInsertionHandlers,HasRowRemovalHandlers,HasRowValueChangeHandlers<RowType>
在PagingScrollTable 作为听者自身注册MutableTableModel,并因此获取更新的非常细粒度的通知.由此产生的实现应该非常高效.