Janier
Janier

Reputation: 4452

p:poll stopped but still fires network call

I have to stop and start a p:poll in JSF using some conditions... I am able to do that by putting the poll in a panelgrid and making the panelGrid rendered... I thought its working since the pollOperationStatus is not called after I made the panelGrid rendered false... When I show it , it restarts as well.. But there is a network call still firing ; which messes up many things ;How to deal it?

 <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>

Upvotes: 1

Views: 342

Answers (1)

Selaron
Selaron

Reputation: 6184

Primefaces 7 Documentation says:

Poll can be started and stopped using client side api; Or bind a boolean variable to the stop attribute and set it to false at any arbitrary time.

In your case this would be in javaScript:

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

Or bind a boolean bean property the the stop attribute of the p:poll:

<p:poll stop="#{myBean.stopPoller}" interval="8" widgetVar="poller" autoStart="true"
                    listener="#{myBean.pollOperationStatus}"
                    update=":#{p:component('newServerID')} :#{p:component('mypollform')}" />

Also beware that component IDs in update attribute are separated by space, not comma.

Upvotes: 2

Related Questions