0

I have a GWT place where a user must create some object before he/she can navigate away from there. I tried using

eventBus.addHandler(PlaceChangeRequestEvent.TYPE, new PlaceChangeRequestEvent.Handler() {
  @Override
  public void onPlaceChangeRequest(PlaceChangeRequestEvent event) {
    event.setWarning("must create the object");
  }
});

but this shows a warning box and then user can click "OK" and still leave the place. I can put the enforcing code to my PlaceController instance, but I thought maybe there was a way to call something like event.cancel() when I get a PlaceChangeRequestEvent instance.

Alex
  • 2,589
  • 3
  • 35
  • 44
  • Have you tried previewing the event, and then canceling it? http://stackoverflow.com/questions/7076004/gwt-event-preview-vs-event-handler – Display name Nov 21 '12 at 23:27

2 Answers2

1

If you use GWTP, you can call PlaceManager's setOnLeaveConfirmation method

spg
  • 9,309
  • 4
  • 36
  • 41
0

There's no way to lock a user in a particular place with the stock PlaceController.

Navigating between places has been modeled after navigating between web pages, because users shouldn't have to even know they're actually not leaving the page: they're in their browser, why would it work differently on that site/app compared to another?

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164