简体   繁体   English

在没有浏览器历史记录更改的情况下寻找有关GWT / MVP操作的输入

[英]Looking for input on GWT / MVP action w/o browser history change

I am trying to develop a GWT app with the MVP pattern. 我正在尝试使用MVP模式开发GWT应用程序。 So far so good except for one specific case of actions: actions that do not change the url (no browser history change). 到目前为止,除了一种特殊的操作情况之外,效果还不错:不更改url的操作(浏览器历史记录不变)。

In the GWT MVP pattern, events are sent from presenters, the an app controller catches them and update the browser history. 在GWT MVP模式中,事件是从演示者发送的,应用控制器会捕获事件并更新浏览器历史记录。 If the history has changed then the view updates. 如果历史记录已更改,则视图将更新。

** MVP with history change (Works well)** **具有历史更改的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 pattern for dialog box w/o history changes 没有历史更改的对话框的GWT MVP模式

** 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? 问题:有人知道在MVP上下文中实现此目标的模式吗?

Any help / idea appreciated. 任何帮助/想法表示赞赏。

Are you using some framework (aside from GWT) that automatically does history changes? 您是否正在使用某些框架(除了GWT之外)会自动更改历史记录?

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. 常规的GWT / MVP不需要更改历史记录,实际上,通常由应用程序来更新历史记录本身。

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. 如果要在不更改历史记录的情况下更新应用程序的状态,则可以使用EventBus发布应用程序其他元素可以订阅的事件,以在不更改历史记录的情况下更新应用程序的状态。

Basically, you will have to create your own PlaceHistoryHandler. 基本上,您将必须创建自己的PlaceHistoryHandler。 Your custom PlaceHistoryHandler will ignore a particular type of PlaceChangeEvent (ie it will not update its Historian). 您的自定义PlaceHistoryHandler将忽略特定类型的PlaceChangeEvent(即,它将不会更新其Historian)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM