Search code examples
javascriptjavawicketwicket-6

Wicket AjaxNewWindowNotifyingBehavior and back button


I'm using Wicket 6.x and I'm having trouble with AjaxNewWindowNotifyingBehavior.

According to the Wicket documentation, this is what it does:

An Ajax behavior that notifies when a new browser window/tab is opened with url to a page instance which is already opened in another window/tab in the same user session

basically, it alerts you when a new window/tab is created.

My problem, is that it is not working properly, because it doesn't trigger only on new window/tab, but also when the user presses the browser's "Back" button, which obviously is messing up my app's logic.

How do I avoid this? Is this a Wicket bug or am I doing something wrong? Here's how I'm using it:

add(new AjaxNewWindowNotifyingBehavior("compila") {
    private static final long serialVersionUID = 1L;

    @Override
    protected void onNewWindow(AjaxRequestTarget target) {
        //Do whatever...
    }
});

Any ideas? Is there any way to detect whether the behavior triggered due to a new tab as opposed to a back button press?


Solution

  • This is a bug in AjaxNewWindowNotifyingBehavior:

    It detects a new window, when an 'old' page is rendered into its original window, whose name has been changed by another page in the meantime.

    See https://issues.apache.org/jira/browse/WICKET-6479