(1) 提交者不应依靠“家庭调查”的植被,其原因有:
- Separating of UI representation in Views and application logic in Presenter
- Defined in interfaces behaviour of View and Presenter
- Easy to write Unit-tests for presenter layer
- Several views(desktop, mobile, e.t.c.) for one presenter
简单一套名为MVP的接口使我们能够将这两级分开:
// View interface
interface View extends AsWidget {
void setPresenter(Presenter presenter); // cross reference to presenter
interface Presenter { // presenter must extends from this interface
void onContactEditClick(); // callback from view handling in presenter without any UI code
}
}
// View realization (part)
public class ViewImpl extends Composite implements View {
@UiHandler( someButton ) // or somelink , e.t.c.
void onContactEditClick(ClickEvent event) {
presenter.onContactEditClick();
}
}
Presenter is isolated from controls that firing events. It can be button, can be link, e.t.c. So it is possible to create several implementations of views(for desktop and mobile platforms for example) with a different set of UI controls in each view and use this views with a one presenter.
rel=“nofollow” 页: 1
2) 名单编制者与数据交换控制有关。 我认为,通过点1样本中的接口方法,最好避免在观众和观众之间使用听众。 事实上,观点接口内的传译员接口是所有来自不同观点的活动的更好的听众。
同样。 HasClick 汉斯人与视角层有关,应当与在场者分开。