简体   繁体   中英

Passing controls / values between presenters , GWT Model View Presenter?

A rookie here. I have this specific issue in implementing Model View Presenter Pattern using GWT in one of my use cases.

I just started with Ray Ryan's Google IO talk and following some articles on Google Developers site. I have not used any of the GWT add-ons like GWTP or MVP4G or GIN or any other stuff. Just followed the contacts example on the GWT site and tried to model my case.

Here's the issue.

I have my AppController onValueChage method like this

   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);
     }
    }
}

And my app flows like this, first Display then a selection in there causes a Dialog and then Dialog sets some variable. And then after the Dialog is hidden, i need to comeback to my original Display and carry on. But the problem is i'm not able to come back to my original DisplayPresenter with the same view because i end up creating a new instance of the presenter whenever there's a history change.

All the things in bold are separate presenters which extends the Presenter and all of them have specific views.

Questions ? 1. Help me come out of this limbo of creating new instances of the presenters everytime there's a history change.

  1. Is there a way in MVP pattern to pass controls between presenters with values persisting ?

  2. How to load a existing instance of a presenter inside app controller on an event fire?

  3. How to load a existing instance of a presenter inside app controller on an event fire?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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