Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
GWT 2.1 中的 Data Presentation Widgets 似乎将它们全部缝合起来:模型、视图和演示者。那么,所有这些数据表示的优点如何与 MVP 相适应呢?例如; 我如何将演示者(又名活动)实例与 CellTree 的节点相关联?这甚至是我应该尝试做的事情吗?
编辑(阐述):
TreeViewModel 属于哪里?它是视图的一部分,还是演示者的一部分?以及如何获得对树的子分支的 ListDataModel 的引用?
可以将您的视图引用给您的演示者,反之亦然。如果您的 CellTree 需要访问您的演示者,请在 CellTree 中定义一个类似 setPresenter 的函数。
另一种解决方案是创建附加到您的视图的事件处理程序,然后让您的演示者侦听这些事件并通过调用您的视图接口来响应。更少耦合,更冗长。我喜欢为我的 Presenter 和我的 View 创建通用接口,以使它们完全分开,但仍然避免处理 EventHandlers。