1
votes

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

1 Answers

1
votes

With respect to passing state information between presenters (question #1) it might be helpful to check out Places.