Wicket 多标签 ajax &页面序列化 [英] Wicket multi-tab ajax & page serialization

查看:26
本文介绍了Wicket 多标签 ajax &页面序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VMWare Horizo​​n 上的 WicketAjax 有一个令人讨厌的问题.用户看到的是 ajax-links 没有按预期工作.确切地说:它们可以工作,但似乎对旧版本的页面起作用.例如,当我有一个计数器时,它似乎确实处理了 ajax 更新,但该值永远不会增加.该值存储在 Model 中,所以我认为它与页面序列化有关.

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.

我接着做了一个更简单的实验:关于 Wicket-Exmaples(参见:http://www.wicket-library.com/wicket-examples/ajax/on-change-ajax-behavior)有一个输入框.如果您按 enter,该值将提交到页面.这在一个浏览器标签中运行良好.

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.

但是,如果我打开两个标签(通过在新标签中复制粘贴网址,我们称它们为 AB).我使用回车在标签 A 中提交了一个值.我刷新标签 B 并获取标签 A 中提交的值.

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.

如何防止这种行为?

ps.我使用 Wicket 版本 6.19.0,wicket 示例似乎运行 6.x.ps2.我在 Chrome 中注意到了这种行为.

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

推荐答案

为了防止这种情况发生,您应该确保在同一页面上没有打开两个或多个选项卡(即具有相同的页面 ID).您可以使用 https://github.com/apache/wicket/blob/2f3b357703df3fe5c49580b3c46d4fd231208474/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxNewWindowNotifyingBehavior.java 在发生这种情况时得到通知.只需执行 setResponsePage(getPage().getClass()) 即可开始新的实例.

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.

这篇关于Wicket 多标签 ajax &页面序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆