在每个时间间隔调用 update="。有没有办法仅在轮询停止时调用更新,并且只调用一次?
Eksample:当轮询停止时,如何仅更新一次按钮片段?
<p:poll interval="2" update="@(.button-fragment)" stop="#{stopMethod()}">
编辑:我想从视图中执行此操作
除了你的民意调查永远不会停止之外,我会做一些类似的事情
<p:poll interval="2" stop="isPollStopped()" listener="updateOnPollStop()">
并在视图中 豆
public boolean isPollStopped() {
return ...;
}
public void updateOnPollStop() {
final boolean pollStopped = this.isPollStopped();
if (pollStopped) {
RequestContext.getCurrentInstance().update("@(.button-fragment)");
}
}
编辑:
完全没有经过测试,但也许这可能有效:
<p:poll interval="2" oncomplete="handlePollComplete(xhr, status, args)" stop="#{stopMethod()}">
function handlePollComplete(xhr, status, args) {
if (!PF(<YOUR_POLL_ID>).active) {
PF(<YOUR_UPDATEE_ID>).update()
}
}
编辑 2(使用 remoteCommand
(
<p:remoteCommand name="updateOnPollStop" update="@(.button-fragment)"/>
<p:poll widgetVar="myPoll" interval="2" oncomplete="handlePollComplete(xhr, status, args)" stop="#{stopMethod()}">
function handlePollComplete(xhr, status, args) {
if (!PF('myPoll').active) {
updateOnPollStop()
}
}