A global popup as place?

222 views
Skip to first unread message

z00bs

unread,
Oct 25, 2010, 7:05:53 PM10/25/10
to GWTP
I'm trying to implement a global popup that acts like a place (i.e.,
has an assigned name token).
What I've done so far to achieve this is implementing my
PopupPresenter (extends PresenterWidget) and its associated PopupView
(extends PopupViewWithUiHandlers). The presenter exposes a method
setDisplayedPresenter(PresenterWidget<?> presenterToDisplay) to set
the content of the popup.
We have several presenters that should now be displayed in this global
popup when they're revealed. How would you do that? If I fire a
RevealRootPopupContentEvent how am I supposed to handle a back click
or the closing of the popup?

I'm stuck here and not sure if I'm taking the wrong road.

Thanks for your help!

Philippe Beaudoin

unread,
Oct 26, 2010, 3:47:54 PM10/26/10
to gwt-pl...@googlegroups.com
You can nest PresenterWidgets inside one another as you do for regular
presenters. In this case, you could setInSlot() or addToSlot() the
other PresenterWidget inside your popup presenter.

Also, I've never tried making a Presenter with a PopupView, but I'm
almost sure it can be done. If you want these sub-presenters to be
attached to name tokens (and be Presenter rather than PresenterWidget)
then you can try making to top-level a Presenter with a PopupView.
Just fire RevealRootPopupContentEvent in its revealInParent method.

Hope it helps,

Philippe

z00bs

unread,
Oct 27, 2010, 3:50:28 AM10/27/10
to GWTP
Thanks for your answer! I'll try the combination of Presenter and
PopupView. Will let you know if it works :).

One last thing: If I reveal the popup by firing a
RevealRootPopupContentEvent what am I supposed to do when the user
closes the popup (which is basically a step back in the history)?
Related to that question: how can I dispose the popup when the user
clicks back?

Thanks

On Oct 26, 9:47 pm, Philippe Beaudoin <philippe.beaud...@gmail.com>
wrote:
> You can nest PresenterWidgets inside one another as you do for regular
> presenters. In this case, you could setInSlot() or addToSlot() the
> other PresenterWidget inside your popup presenter.
>
> Also, I've never tried making a Presenter with a PopupView, but I'm
> almost sure it can be done. If you want these sub-presenters to be
> attached to name tokens (and be Presenter rather than PresenterWidget)
> then you can try making to top-level a Presenter with a PopupView.
> Just fire RevealRootPopupContentEvent in its revealInParent method.
>
> Hope it helps,
>
>     Philippe
>

Philippe Beaudoin

unread,
Oct 27, 2010, 4:44:44 AM10/27/10
to gwt-pl...@googlegroups.com
Just calling getView().hide() should dispose of the popup and
unregister it from its parent presenter. Now, doing this with a popup
presenter this is a bit weird because the history token wont change...

You can also simply navigate to the page you want. To close the popup
in this case make sure you call hide() before navigating. If you want
to close the popup whenever you navigate you can call
setAutoHideOnNavigationEventEnabled(true) in your view's constructor.

Cheers,

Philippe

Dominik Mayer

unread,
Feb 10, 2012, 12:08:21 PM2/10/12
to gwt-pl...@googlegroups.com
I implemented the Presenter + PopupWidget as suggested but there is one problem: If I enter the application at #popupPlace, I only see the popup, not the presenter behind it. Is there any way to get the name token of the last place? In that case I could detect if the user came from another place and reveal a default place if not.

Dominik Mayer

unread,
Feb 10, 2012, 11:03:43 PM2/10/12
to gwt-pl...@googlegroups.com

Yannis Bres

unread,
Apr 22, 2012, 7:04:46 PM4/22/12
to gwt-pl...@googlegroups.com
Dominik, I just walked into your shoes and proposed a solution or, at least, a workaround, in Issue 106.

Hope this will help.

Best regards,
          Yannis

Christian Goudreau

unread,
Apr 24, 2012, 11:24:49 AM4/24/12
to gwt-pl...@googlegroups.com
Another work around would be to have the popup nested in a place presenter. That's usually how I handle this kind of situation.
--
Christian Goudreau

Dominik Mayer

unread,
Apr 24, 2012, 11:32:20 AM4/24/12
to gwt-pl...@googlegroups.com
Does that allow you to use the popup in different places?

@Yannis: Thanks, I'll have a look at it.

Christian Goudreau

unread,
Apr 24, 2012, 11:36:07 AM4/24/12
to gwt-pl...@googlegroups.com
Yes, you can factor out the "popup" into it's own widget that you can add to any Place presenter you want.
--
Christian Goudreau

Jonas Zuberbuehler

unread,
May 31, 2012, 11:00:48 AM5/31/12
to gwt-pl...@googlegroups.com
If I get you right Christian, what you do is to create a place presenter (PresenterA extends Presenter) that reveals itself (in revealInParent()) to some dummy slot defined in some parent presenter. To reveal the popup (PresenterB extends PresenterWidget) you let PresenterB inject into PresenterA and in onReveal() of PresenterA you call RevealRootPopupContentEvent (for a global popup) or addToPopupSlot() with the injected instance of PresenterB.

Is that right?

Christian Goudreau

unread,
May 31, 2012, 11:34:39 AM5/31/12
to gwt-pl...@googlegroups.com
Yes!
--
Christian Goudreau

Jonas Zuberbuehler

unread,
May 31, 2012, 3:09:54 PM5/31/12
to gwt-pl...@googlegroups.com
Ok, thanks :). Wasn't sure about the dummy slot.

I guess it would also be possible to inject the parent presenter (PresenterC) of PresenterA as well as PresenterB into PresenterA itself and then call addToPopupSlot() on PresenterC with PresenterA. Is ugly as hell (the child must know its parent and therefore can only be used in conjunction with it) but I guess it would do the trick.

Christian Goudreau

unread,
Jun 3, 2012, 1:41:27 PM6/3/12
to gwt-pl...@googlegroups.com
Well the way I see this and maybe I don't undrestand correctly but:

PresenterA is the root of your app and isn't a place.
PresenterB is the place where PopupPresenterC is injected.

When presenterB is revealed, popupPresenterC is shown. And PresenterB is revealed inside PresenterA.

That's a basic flow, but I hope it clarify what I meant :D
--
Christian Goudreau

Jonas Zuberbuehler

unread,
Jun 4, 2012, 8:30:48 AM6/4/12
to gwt-pl...@googlegroups.com
Jep, that's exactly how I do it too. The only odd thing is that for PresenterB we must add a dummy slot to PresenterA and define a dummy view which does nothing. But afaik there is already an issue for that.

Christian Goudreau

unread,
Jun 4, 2012, 9:56:13 AM6/4/12
to gwt-pl...@googlegroups.com
Well normally I go even further by not using PopupPresenter and by using a PopupPanel in that dummy view :D
--
Christian Goudreau

Jonas Zuberbuehler

unread,
Jun 4, 2012, 3:44:04 PM6/4/12
to gwt-pl...@googlegroups.com
Hmm so you get completely rid of PopupPresenterC and your ViewB is a PopupViewImpl?

Is the following possible to achieve: make the LocalDialogPresenterWidget of the gwtp-sample-tab accessible via name token such that it still behaves like a local popup? So if a user browses to #!localDialog (the new name token) the LocalDialogSubTabPresenter should be revealed with the dialog showing up. Browsing to #!localDialogPage the LocalDialogSubTabPresenter should be revealed but without dialog?

I think that this is not possible.

Christian Goudreau

unread,
Jun 4, 2012, 5:08:57 PM6/4/12
to gwt-pl...@googlegroups.com
It's not a popupViewIMpl :D It's just a ViewImpl that has a Popup widget in it's .ui.xml file.

Yes it is, but it's a little bit more complicated because there's known issues with having a place as a parent...
--
Christian Goudreau
Message has been deleted

Jonas Zuberbuehler

unread,
Jun 5, 2012, 3:01:21 AM6/5/12
to gwt-pl...@googlegroups.com
:) ok ok, in the end it needs to be a PopupPanel, got that ^^

Can you share an example with a local popup and its parent both as places or give me some hint on how to reveal the popup? When I create a small (dummy) place presenter for the popup and call addToPopupSlot(popup) in onReveal() in it, it reveals the local popup and it behaves as desired. But closing the popup, switching the tab it was displayed in and coming back, reveals it again. This is because the dummy presenter is still set in slot of the tab. Do I have to somehow catch the close event of the popup?

Christian Goudreau

unread,
Jun 5, 2012, 1:55:50 PM6/5/12
to gwt-pl...@googlegroups.com
That is tricky since the parent is a place, which is not well supported by GWTP.

What you can do is to have two slot in the same presenter, when you show the popup, you call removeFromSlot on the other one and when is the tab, you call removeFromSlot from the popup and you hide it.

What it will have as effect is that the presenter will be unregistered from the presenter hiarchy while still being visible (to onReset will work on it though).

And no I have no public example at the moment :(
--
Christian Goudreau

Arpit Tripathi

unread,
Nov 14, 2014, 8:00:04 PM11/14/14
to gwt-pl...@googlegroups.com
I followed the ideas discussed here and I'm able to create a place which displays a popup view by adding a dummy slot to application presenter. I'm using GWT-Bootstrap's Modal widget. When placeManager navigates me to such presenter, URL also gets updated. However, once modal is hidden (user presses ESC or clicks outside modal) then URL doesn't change back to original place. 

How should I update the URL back to original place when user action hides the modal?
Reply all
Reply to author
Forward
0 new messages