a4j:轮询计时器重置

时间:2012-02-10 15:45:48

标签: jsf richfaces

我正在使用a4j:poll每隔X秒调用一次actionListener(可在辅助bean中配置)。但是,如果我重新加载页面计时器重置,有什么办法可以防止这种情况吗?

Example:   I set the interval to 30000 (30 seconds)
Second 0:  The page is loaded for the first time
Second 15: I reload the page, by pressing F5 or by clicking on a link to the same page
Second 30: I expect the actionListener to be called but nothing happens
Second 45: The actionListener finally gets called, exactly 30 seconds after the reload

1 个答案:

答案 0 :(得分:1)

我会说不。从ajax中部分重新加载不会重置计时器,但重新加载整个页面会重新启动所有javascript,所以所有轮询器都会重新启动。

您可以使用'push'来执行后端触发而不是轮询。后端可以使用一个servlet,它只需每30秒触发一次,与用户在前端的操作无关。使用RichFaces 4.2,推送非常容易实现。

MAG, Milo van der Zee