问题
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.
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/29508123/wicket-multi-tab-ajax-page-serialization