Rob Audenaerde
Rob Audenaerde

Reputation: 20019

Wicket multi-tab ajax & page serialization

I have a nasty issue with Wicket and Ajax on VMWare Horizon. What users see is that ajax-links do not work as expected. To be exact: they work, but seem to act on a older version of the page. For example, when I have a counter, it does seems to handle an ajax-update, but the value is never increased. The value is stored in a Model so I figured it has something to do with page serialization.

I went on to do a more simpler experiment: on the Wicket-Exmaples (see: http://www.wicket-library.com/wicket-examples/ajax/on-change-ajax-behavior) there is a input box. If you press enter, the value is submitted to the page. This works fine in one browser tab.

However, if I open two tabs (by copy-pasting the url in a new tab, let's call them A and B). I submit a value in tab A using enter. I refresh the tab B and get the value what is submitted in tab A.

The only way this can happen seems to be that they read each-other's serialized pages.

How can I prevent this behaviour?

ps. I use Wicket version 6.19.0, the wicket examples seems to run 6.x. ps2. I noticed this behaviour in Chrome.

Upvotes: 0

Views: 1379

Answers (2)

martin-g
martin-g

Reputation: 17503

To prevent this you should make sure that there are no two or more tabs opened on the same page (i.e. with the same page id). You can use https://github.com/apache/wicket/blob/2f3b357703df3fe5c49580b3c46d4fd231208474/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxNewWindowNotifyingBehavior.java to be notified when this happens. Just do setResponsePage(getPage().getClass()) to start on a fresh instance.

Upvotes: 2

Glenner003
Glenner003

Reputation: 1552

That is because two tabs work in one session.

The tabs are not considered (because they are not known to the server) for deciding which session a request is for.

If you would do the same with two browsers instead of two tabs it would work fine.

Upvotes: 0

Related Questions