警告用户在 GWT 中离开以查看另一个视图时,他将失去在编辑视图中的更改
Warn the user that he is about to loose his change in Edit view when leaving to view to another in GWT
我想防止用户在将视图更改为另一个视图时丢失对 EditView 的更改。
我在我的项目中使用 MVP4G 并且该项目被划分为 mvp 的结构(一个包用于模板,另一个包用于视图..)是否有任何解决方案来检测 eventBus 中的 EditView。或检测显示给用户的当前视图
提前致谢
由于 mvp4g 中的导航事件功能,演示者将在视图更改之前获得控制权。此时演示者可以决定是否完成导航。这是 mvp4g 应用程序中保存数据的正确位置。
首先 zu 必须在事件总线中标记所有将改变您的视图的事件:
@Event(..., navigationEvent = true)
void goToPage1();
接下来您的演示者必须实现 NavigationConfirmationInterface 和要求的确认方法:
public class Presenter extends ... implements NavigationConfirmationInterface {
public void confirm(NavigationEventCommand event) {
//pseudo method to verify if the view has changed
if (isViewModified(){
//Window shouldn't be used inside a presenter
//this is just to give a simple example
if (Window.confirm("Are you sure you want to leave?")){
event.fireEvent();
}
} else {
event.fireEvent();
}
}
}
最后要做的是通过调用将当前视图的演示者设置为确认演示者:
event.fireEvent(false);
这通常在演示者获得控制权时完成。
您将在此处找到文档:
https://github.com/FrankHossfeld/mvp4g/wiki/03.-Defining-EventBus#navigation-event
感谢 MVP4G 的团队,包括 El Hoss,他们给了我检查 MVP4G 博客的提示。我已经按照这个例子解决了我的问题
http://mvp4g.blogspot.com/2011/06/navigation-control.html
我想防止用户在将视图更改为另一个视图时丢失对 EditView 的更改。
我在我的项目中使用 MVP4G 并且该项目被划分为 mvp 的结构(一个包用于模板,另一个包用于视图..)是否有任何解决方案来检测 eventBus 中的 EditView。或检测显示给用户的当前视图
提前致谢
由于 mvp4g 中的导航事件功能,演示者将在视图更改之前获得控制权。此时演示者可以决定是否完成导航。这是 mvp4g 应用程序中保存数据的正确位置。
首先 zu 必须在事件总线中标记所有将改变您的视图的事件:
@Event(..., navigationEvent = true)
void goToPage1();
接下来您的演示者必须实现 NavigationConfirmationInterface 和要求的确认方法:
public class Presenter extends ... implements NavigationConfirmationInterface {
public void confirm(NavigationEventCommand event) {
//pseudo method to verify if the view has changed
if (isViewModified(){
//Window shouldn't be used inside a presenter
//this is just to give a simple example
if (Window.confirm("Are you sure you want to leave?")){
event.fireEvent();
}
} else {
event.fireEvent();
}
}
}
最后要做的是通过调用将当前视图的演示者设置为确认演示者:
event.fireEvent(false);
这通常在演示者获得控制权时完成。
您将在此处找到文档:
https://github.com/FrankHossfeld/mvp4g/wiki/03.-Defining-EventBus#navigation-event
感谢 MVP4G 的团队,包括 El Hoss,他们给了我检查 MVP4G 博客的提示。我已经按照这个例子解决了我的问题 http://mvp4g.blogspot.com/2011/06/navigation-control.html