Wicket multi-tab ajax & page serialization

喜你入骨 提交于 2019-12-12 01:54:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!