I'm having trouble using the PlaceChangeRequestEvent.setWarning
method. I'm trying to implement functionality that is supposed to warn
a user about unsaved changes upon a requested place change. This is
the code I'm using:
eventBus.addHandler(PlaceChangeRequestEvent.TYPE, new
PlaceChangeRequestEvent.Handler() {
@Override
public void onPlaceChangeRequest(PlaceChangeRequestEvent event) {
if (hasUnsavedChanges()) {
event.setWarning(getUnsavedChangesWarning());
}
}
});
The warning dialog box pops up fine, and upon clicking "cancel" (in
order to prevent the place change), the application indeed doesn't
navigate to the new place. However, the url in the browser's address
bar does display the new history token, as if the place *was* changed.
In fact, I already see the new token in the url before I've even
clicked either of the buttons in the dialog box. This leaves the
application in an inconsistent state: the url does not match the place
I'm seeing. Subsequent requests of the same place change have no
effect anymore.
Is this functionality broken, or am I doing something wrong? I'm using
GWT 2.4 and have tested this in Chrome15, FF7 and IE9. The problem is
not restricted to hosted mode.
Any help would be greatly appreciated.
Thanks,
Ralf