寻找有关 GWT / MVP 操作(无需浏览器历史记录更改)的输入
我正在尝试使用 MVP 模式开发 GWT 应用程序。到目前为止一切都很好,除了一种特定的操作情况:不更改 url 的操作(没有浏览器历史记录更改)。
在 GWT MVP 模式中,事件从演示者发送,应用程序控制器捕获它们并更新浏览器历史记录。如果历史记录发生更改,则视图会更新。
** 具有历史记录更改的 MVP(效果很好)**
Current URL is /list
User clicks on contactdelete button.
Fire DeleteContactAction event.
App controller catches, change history to 'delete'
onValueChange is called
if (token.equals("delete"))
delete contact screen, then delete contact
Fire ContactDeletedEvent
app controller catches and change the history to list
onValueChange is called: contact list refreshes
用于无历史记录更改的对话框的 GWT MVP 模式
** 问题 ** - 我使用对话框,并且不想更改浏览器历史记录,所以这里是问题:
Current URL is /list
User clicks on contactdelete button.
Contact is deleted
Fire ContactDeletedEvent.
App controller catches, change history to 'list'
**onValueChange is NOT called** because url is already /list and there is no change
# problem: contact list does not refresh
问题:有谁知道在 MVP 背景下实现这一点的模式吗?
任何帮助/想法表示赞赏。
I am trying to develop a GWT app with the MVP pattern. So far so good except for one specific case of actions: actions that do not change the url (no browser history change).
In the GWT MVP pattern, events are sent from presenters, the an app controller catches them and update the browser history. If the history has changed then the view updates.
** MVP with history change (Works well)**
Current URL is /list
User clicks on contactdelete button.
Fire DeleteContactAction event.
App controller catches, change history to 'delete'
onValueChange is called
if (token.equals("delete"))
delete contact screen, then delete contact
Fire ContactDeletedEvent
app controller catches and change the history to list
onValueChange is called: contact list refreshes
GWT MVP pattern for dialog box w/o history changes
** Issue ** - I use a dialog box and I don't want to change the browser history, so here is the problem:
Current URL is /list
User clicks on contactdelete button.
Contact is deleted
Fire ContactDeletedEvent.
App controller catches, change history to 'list'
**onValueChange is NOT called** because url is already /list and there is no change
# problem: contact list does not refresh
Question: does anyone know a pattern to implement this in the context of MVP?
Any help / idea appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否使用某些自动更改历史记录的框架(GWT 除外)?
常规 GWT/MVP 不需要更改历史记录,事实上通常由应用程序自行更新历史记录。
如果要更新应用程序的状态而不更改历史记录,可以使用 EventBus 发布应用程序的其他元素可以订阅的事件,以更新应用程序的状态而不更改历史记录。
Are you using some framework (aside from GWT) that automatically does history changes?
Regular GWT/MVP doesn't require a history change to be made, and in fact usually it's up to the app to update the history itself.
If you want to update the app's state without a history change, you can use an EventBus to publish events that other elements of the app can subscribe to, to update the app's state without a history change.
基本上,您必须创建自己的 PlaceHistoryHandler。您的自定义 PlaceHistoryHandler 将忽略特定类型的 PlaceChangeEvent(即,它不会更新其历史记录)。
Basically, you will have to create your own PlaceHistoryHandler. Your custom PlaceHistoryHandler will ignore a particular type of PlaceChangeEvent (i.e. it will not update its Historian).