我认为你是在正确的轨道,使弹出自包含,并保持它的一个单一的实例,如果你可以帮助它。
就编辑的细节而言,什么是没有意义的?总体思路是,您可以创建一次驱动程序,使用弹出窗口(实现编辑器)对其进行初始化,然后在每次准备使用新模型显示驱动程序时调用驱动程序上的编辑。
我平时喜欢的东西结束(假设该类扩展弹出,实现了编辑器,并已内部定义的驱动程序)
public MyPopup() {
//uibinder or other layout
this.driver = GWT.create(Driver.class);
driver.initialize(this);
}
public void edit(MyModel model) {
driver.edit(model);
show();
}
调味这个答案与我自己的方法/偏见,我喜欢一个MVP设置视图和演示者都是界面的位置,以及演示者impl不知道视图最终如何绘制的位置。通常看起来像有关这对我来说
public interface MyModelEditorView extends Editor<MyModel> {
// this param is used in a mobile/table situation, where popups aren't as friendly
void show(AcceptsOneWidget parent);
// exposes the driver for the presenter *
SimpleBeanEditorDriver<MyModel, ?> getDriver();
void setPresenter(Presenter presenter);
public interface Presenter {
// this is the only method that is called externally
void show(AcceptsOneWidget parent, MyModel model);
// called by click handlers in the view impl, probably by @UiHandler methods
void onSaveClicked();
void onCancelClicked();
}
}
*主持人或许应该控制驱动器,因此它可以检查错误,如果需要在错误从服务器传,编辑的新车型,并冲洗出来的结果。
谢谢,我最终做了类似的事情 - 我为3个视图使用了1个活动:实际的主要assignView,checkoutPopup和checkinPopup,并使用1个活动作为结帐和签入弹出窗口的编辑器 - 我不知道如果这有问题,但它似乎工作正常 – 2012-01-30 00:50:46