p:投票停止,但仍会触发网络通话

时间:2019-03-28 01:26:57

标签: jsf primefaces backing-beans

我必须使用某些条件在JSF中停止并启动p:poll……我可以通过将民意调查放在panelgrid中并渲染panelGrid来实现这一点……我认为自我将panelGrid渲染为false后,不会调用pollOperationStatus。当我显示它时,它也会重新启动。 但是还有一个网络呼叫还在触发;弄乱了很多东西;如何处理?

 <h:form>
    My main form
    </h:form>

        <h:form id="mypollform">

            <p:outputLabel id="currentTime" value="#{myBean.counter}" />
            <h:outputText value="#{myBean.startPoll}" id="counter11" />

            <p:panelGrid rendered="#{myBean.startPoll}">
                <p:poll interval="8" widgetVar="poller" autoStart="true"
                    listener="#{myBean.pollOperationStatus}"
                    update=":#{p:component('newServerID')},:#{p:component('mypollform')}" />
            </p:panelGrid>
        </h:form>

1 个答案:

答案 0 :(得分:2)

Primefaces 7 Documentation says

  

可以使用客户端api启动和停止轮询;或绑定一个   将布尔变量设置为stop属性,并在任何情况下将其设置为false   任意时间。

在您的情况下,该位置应为javaScript

PF('poller').stop();PF('poller').start();

或将boolean bean属性绑定到stop的{​​{1}}属性中:

p:poll

还要注意<p:poll stop="#{myBean.stopPoller}" interval="8" widgetVar="poller" autoStart="true" listener="#{myBean.pollOperationStatus}" update=":#{p:component('newServerID')} :#{p:component('mypollform')}" /> 属性are separated by space, not comma.中的组件ID