Place that dispatches to presenter bases on parameters

Skip to first unread message

David Nouls

Dec 1, 2016, 8:00:42 AM12/1/16
I'm a bit new to gwtp. The docs do not really go in much detail for more complicated setups.

I want to map a specific place to a presenter depending on parameters or even async information.
For example I have a url: message?id=messageId
This should load the details of that message and depending on meta info this should show one view or another one.

How do I do this with GWTP ? Can I somehow intercept an event and the implement some logic to start the right presenter ?

Harsh Yadav

Dec 4, 2016, 8:27:08 PM12/4/16
You can read the messageId from the history in your prepareFromRequest method of the presenter:

itsPlaceManager.getCurrentPlaceRequest().getParameter("id", "")

After, you have retrieved the message metadata, you can load appropriate view in different slots.

So for e.g. lets say you have 2 slots for 2 message types in your presenter:

public static final Slot SLOT_MESSAGE_1 = new Slot();
public static final Slot SLOT_MESSAGE_2 = new Slot();

And representing these 2 slots, your 2 presenter widgets:

private Message1PresenterWidget itsMessage1PresenterWidget;
private Message2PresenterWidget itsMessage2PresenterWidget;

depending on the message metadata, you set the appropriate slot:

if (message1) {
(SLOT_MESSAGE_1, itsMessage1PresenterWidget);
} else if () {
(SLOT_MESSAGE_2, itsMessage2PresenterWidget);

In your presenter's view, you'll need to have placeholders for these 2 slots

You can get more details here:

I would also recommend checking out the beestore example from Arcbees github:


Dec 5, 2016, 3:27:55 AM12/5/16
Thanks for the answer.

I guess one slot will be more than enough since they will never show at the same time. I already have such a thing setup in my main application presenter. I was hoping to have a presenter without a view but one that drives other presenters that will use the main application view slot.

What I am also missing a bit is how to share more than just some strings between presenters. (Through the place requests)

My main logic will call a REST service to load the contents of the message and then based on some custom criteria it will decide what sub-presenter will be handling the data. But I want to avoid loading the message twice.

Can I use a custom event that would include the message payload and somehow dispatch it to the child presenters ? I have seen some code that show a tab deck and it is using some annotations to determine the pages and to switch between them. Can I somehow do something similar ?
You received this message because you are subscribed to a topic in the Google Groups "GWTP" group.
To unsubscribe from this topic, visit
To unsubscribe from this group and all its topics, send an email to
For more options, visit

Harsh Yadav

Dec 5, 2016, 9:58:53 AM12/5/16
To share data b/w presenters, you can use the event-bus.

So for e.g. you have a main presenter, which shows some common data b/w multiple presenters.

------------Application Presenter (top-level application presenter)--------------
public interface MyProxy
extends Proxy<ApplicationPresenter> {

------------Main Presenter (Nested inside application presenter slot. This also extends Proxy)----------------------
public interface MyProxy
extends Proxy<MainPresenter> {

------------Child Presenter (1 or 2 as slots inside MainPresenter. These extend ProxyPlace)--------------
@NameToken (NameTokens.CHILD)
public interface MyProxy
extends ProxyPlace<ChildPresenter> {

Inside onReveal() of your MainPresenter, make the REST call, and fire the event (with data) via the EventBus.

Depending on which place (history token) you are at, the appropriate child presenter would receive that data, and show its content.
When you navigate to the second child presenter, it wouldn't have to do the REST call again, as it already has the data from the event bus.

Hope that answers your question or is the scenario you are facing.


Dec 5, 2016, 2:39:11 PM12/5/16
yes indeed. That is exactly what I needed? Thanks
Reply all
Reply to author
0 new messages