Thursday, July 5, 2012

Communication between presenters? Passing controls, GWT Model View Presenter query?

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.

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

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

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment