寻找有关 GWT / MVP 操作(无需浏览器历史记录更改)的输入

发布于 2024-08-28 23:24:58 字数 1035 浏览 9 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

抱猫软卧 2024-09-04 23:24:58

您是否使用某些自动更改历史记录的框架(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.

小猫一只 2024-09-04 23:24:58

基本上,您必须创建自己的 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文