Repeated revealPlace() has no effect

216 views
Skip to first unread message

Ralph Brecheisen

unread,
May 22, 2012, 9:20:48 AM5/22/12
to gwt-pl...@googlegroups.com
Hi,

I'm working on a GWTP-based desktop application where the desktop itself is a presenter/view pair and each desktop app also. Whenever I select a shortcut on the desktop, a revealPlace() for the corresponding application is issued and the application's window is shown in the desktop view's setInSlot(). When I close the window, I catch the onHide() event (it's a GXT window) and call revealDefaultPlace() to go back to the desktop itself. However, if I click the application shortcut again nothing happens. The browser URL is updated to the applications' name token but the setInSlot() of the desktop view is not called for some reason.

I cannot figure out why setInSlot() is not called every time the application's presenter is revealed.

Any ideas?

Ralph

Christian Goudreau

unread,
May 23, 2012, 9:59:21 AM5/23/12
to gwt-pl...@googlegroups.com
When do you call setInSlot? In onBind()? or onReveal?
--
Christian Goudreau

Ralph Brecheisen

unread,
May 23, 2012, 10:05:40 AM5/23/12
to gwt-pl...@googlegroups.com
Hi Christian,

I'm not calling it anywhere. I just do placeManager.revealPlace("!desktopApp"). The first time, this triggers the revealInParent() of the desktop app presenter, after which through the GWTP internals setInSlot() of the desktop view is called. However, the second time, the place manager call does not result in a revealInParent() of the app presenter. I don't understand why it gets blocked. I saw an earlier post by Philippe that the place manager checks if the nametoken has changed or something but since I switch back the parent presenter (the desktop containing the desktop app), also using the placemanager, I would expect the name token to have changed accordingly. Then the second call to reveal the desktop app, should be a "new" one. Still, it does not respond....

Hope this gives you some ideas. Perhaps I should call setInSlot() directly but from where and with what parameters? This is not clear to me.

Thanks for replying!

Rlp

Christian Goudreau

unread,
May 23, 2012, 10:14:45 AM5/23/12
to gwt-pl...@googlegroups.com
Well you do seem to have a problem of "visibility", popups are tricky if you want to bind them to the history. What I usually do is to reveal and hide the ui part manually in onReveal and onHide.

What I'm not clear is to when do you close your popup? because you shouldn't change the place in onHide... onHide will be called when you change the place!
--
Christian Goudreau

Ralph Brecheisen

unread,
May 23, 2012, 10:44:33 AM5/23/12
to gwt-pl...@googlegroups.com
Well the reason why I wanted to bind them to the history is that it allows the user to switch between desktop app windows using the back/forward buttons, kind of like Alt-Tab on windows. It's not an essential feature so maybe I should do this differently and not use place requests. Actually what I consider to be the most important thing is the lazy loading of desktop apps and their windows. Our desktop may potentially contain many desktop apps, not all of which should be loaded into the browser at startup. I figured that the code splitting feature of GWTP would be perfect for that. However, now that I'm having these problems with revealing the app presenters... I'm not so sure anymore. I've been struggling to get this working for a long time and it all hangs on the place manager's refusal to process my place requests.... (except for the first one that is)

Greetz,

Rlp

Christian Goudreau

unread,
May 23, 2012, 11:17:03 AM5/23/12
to gwt-pl...@googlegroups.com
You can definitely use history :D I've done it several time myself.

Can I take a look at the code somewhere?
--
Christian Goudreau

Ralph Brecheisen

unread,
May 23, 2012, 12:49:17 PM5/23/12
to gwt-pl...@googlegroups.com
Hi Christian,

Thanks for the fast replies. I don't have the code in a public place somewhere but the code below shows the general setup of presenters/views. Note that the Window, Shortcut and Desktop classes are GXT components. The Shortcut class is modified to store the name token of the corresponding AppPresenter. So, my main problem is that the first time I click on the shortcut, the AppPresenter is revealed as expected. In the setInSlot() of the AppView, the widget (which is a GXT window) is added to the Desktop component and then shown. Since this action was triggered by a place request, the URL is updated to the "!app" name token. When I close the GXT window, my idea was to catch the window's HideEvent and issue a place request for the desktop "!desktop". This works but when I click the shortcut again, only the URL is updated but the AppPresenter's revealInParent() is not called, and neither is the setInSlot() of the DesktopView. I tried adding a onReveal() in the AppPresenter to see whether it is called, but it is not. So, that's my situation right now. I don't know maybe you see something funny here. Perhaps the DesktopPresenter should be a place?

Greetz,

Ralph

////////////////////////////////////////////////////////////////////////
public class MainPresenter
extends Presenter<MainPresenter.MyView, MainPresenter.MyProxy> {

  @ProxyStandard
  public interface MyProxy extends Proxy<MainPresenter> {}
  public interface MyView extends View {}

  @ContentSlot
  public static final Type<RevealContentHandler<?>>
    TYPE_SetMainContent = new Type<~>();

  @Inject
  public MainPresenter(EventBus bus, MyView view, MyProxy proxy) {
    super(bus, view, proxy);
  }

  @Override
  public void revealInParent() {
    RevealRootContentEvent.fire(this, this);
  }
}
////////////////////////////////////////////////////////////////////////
public class MainView extends ViewImpl implements MainPresenter.MyView {

  private Viewport viewport = new Viewport();

  public MainView() {
  }

  @Override
  public void setInSlot(Object slot, Widget widget) {
    if(slot == MainPresenter.TYPE_SetMainContent) {
      viewport.clear();
      viewport.add(widget);
    } else {
      super.setInSlot(slot, widget);
    }
  }

  @Override
  public Widget asWidget() {
    return viewport;
  }
}
////////////////////////////////////////////////////////////////////////
public class DesktopPresenter
extends Presenter<DesktopPresenter.MyView, DesktopPresenter.MyProxy> {

  @ProxyCodeSplit
  @NameToken("!desktop");
  public interface MyProxy extends ProxyPlace<DesktopPresenter> {}
  public interface MyView extends ViewImpl {
    Desktop getDesktop();
  }

  @ContentSlot
  public final static Type<RevealContentHandler<?>>
    TYPE_SetDesktopContent = new Type<~>();

  private final PlaceManager manager;

  @Inject
  public DesktopPresenter(
  EventBus bus, MyView view, MyProxy proxy, PlaceManager manager) {
    super(bus, view, proxy);
    this.manager = manager;
  }

  @Override
  protected void revealInParent() {
    RevealContentEvent.fire(
      this, MainPresenter.TYPE_SetMainContent, this);
  }

  @Override
  protected void onBind() {
    super.onBind();
    Shortcut shortcut = new Shortcut("!app");
    shortcut.addSelectHandler(new SelectHandler() {
      @Override
      public void onSelect(SelectEvent event) {
        Shortcut s = (Shortcut) event.getSource();
        manager.revealPlace(new PlaceRequest(s.getNameToken()));
      }
    });
    getView().getDesktop().addShortcut(shortcut);
  }
}
////////////////////////////////////////////////////////////////////////
public class DesktopView extends ViewImpl implements DesktopPresenter.MyView {

  private Desktop desktop = new Desktop();
  public DesktopView() {
  }

  @Override
  public void setInSlot(Object slot, Widget widget) {
    if(slot == DesktopPresenter.TYPE_SetDesktopContent) {
      if(widget instanceof Window) {
        desktop.add(widget);
        desktop.show(widget);
      }
    } else {
      super.setInSlot(slot, widget);
    }
  }

  @Override
  public Desktop getDesktop() {
    return desktop;
  }

  @Override
  public Widget asWidget() {
    return desktop;
  }
}
////////////////////////////////////////////////////////////////////////
public class AppPresenter 
extends Presenter<AppPresenter.MyView, AppPresenter.MyProxy> {

  @ProxyCodeSplit
  @NameToken("!app");
  public interface MyProxy extends ProxyPlace<AppPresenter> {}
  public interface MyView extends ViewImpl {
    Window getWindow();
  }

  private final PlaceManager manager;

  @Inject
  public AppPresenter(
  EventBus bus, MyView view, MyProxy proxy, PlaceManager manager) {
    super(bus, view, proxy);
    this.manager = manager;
  }

  @Override
  protected void onBind() {
    super.onBind();
    getView().getWindow().addHideHandler(new HideHandler() {
      @Override
      public void onHide(HideEvent event) {
        manager.revealPlace(new PlaceRequest("!desktop"));
      }
    });
  }

  @Override
  protected void revealInParent() {
    RevealContentEvent.fire(
      this, DesktopPresenter.TYPE_SetDesktopContent, this);
  }
}
////////////////////////////////////////////////////////////////////////
public class AppView extends ViewImpl implements AppPresenter.MyView {

  private Window window = new Window();
  public AppView() {
  }

  @Override
  public Window getWindow() {
    return window;
  }

  @Override
  public Widget asWidget() {
    return window;

Christian Goudreau

unread,
May 23, 2012, 3:21:53 PM5/23/12
to gwt-pl...@googlegroups.com
You have a nesting problem!

Basically for GWT-Platform you're moving from !App to !Desktop when closing... but when you want to go back to !App, !Desktop as the parent of !app is already shown and thus, it won't go further.

This is an open issue, parents shouldn't be a place. The way to resolve this is to created a empty presenter !Desktop that will have you're current DesktopPresenter and AppPresenter as a child.
--
Christian Goudreau
Reply all
Reply to author
Forward
0 new messages