【问题标题】:Passing controls / values between presenters , GWT Model View Presenter?在演示者之间传递控件/值,GWT 模型视图演示者?
【发布时间】:2012-07-06 02:46:18
【问题描述】:

这里是新手。在我的一个用例中,我在使用 GWT 实现模型视图演示者模式时遇到了这个特定问题。

我刚开始阅读 Ray Ryan 的 Google IO 演讲并关注 Google Developers 网站上的一些文章。我没有使用任何 GWT 附加组件,例如 GWTP 或 MVP4G 或 GIN 或任何其他东西。 只是按照 GWT 网站上的联系人示例并尝试为我的案例建模。

问题来了。

我有这样的 AppController onValueChage 方法

   public void onValueChange(ValueChangeEvent<String> event) {
   if(token != null){
    presenter = null;

    if(token == "display")
    {

    presenter = new DefaultPresenter(rpcService, eventBus, new DefaultView());
    }
    else if(token == "popup")
    {
    presenter = new PopUpPresenter(rpcService, eventBus, new PopUpView());      
    }
    else if(token == "dialog")
    {
    presenter = new DialogPresenter(rpcService, eventBus, new DialogView());
    }

    if (presenter!= null) {
       presenter.go(container);
     }
    }
}

我的应用程序是这样运行的,首先是 Display 然后在其中进行选择会导致 Dialog 然后 Dialog 设置一些变量。然后在 Dialog 隐藏之后,我需要回到我原来的 Display 并继续。但问题是我无法以相同的视图返回到我原来的 DisplayPresenter,因为每当历史发生变化时,我最终都会创建一个新的演示者实例。

粗体中的所有东西都是独立的presenter,扩展了Presenter,它们都有特定的视图。

问题? 1. 每次历史发生变化时,帮助我摆脱创建演示者新实例的困境。

  1. 在 MVP 模式中有没有一种方法可以在值保持不变的情况下在演示者之间传递控件?

  2. 如何在事件触发时加载应用控制器内的现有演示者实例?

  3. 如何在事件触发时加载应用控制器内的现有演示者实例?

【问题讨论】:

    标签: java design-patterns gwt mvp


    【解决方案1】:

    关于在演示者之间传递状态信息(问题 #1),查看Places 可能会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-23
      • 2016-03-01
      • 1970-01-01
      • 2010-10-05
      • 2011-06-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多