Reputation: 169
i am using prime-faces 3.2. Ajax polling is not get stopped, i am using stop attribute to stop the polling and i am trying to stop it form the bean using getter and setters for stop. Even i have used java script to stop but i can't. Any solution to stop polling?
Upvotes: 2
Views: 12420
Reputation: 31
<p:poll id="checkListPoll" interval="2" process="@none"
update="checkList" widgetVar="chkList"/>
<h:panelGroup id="checkList"> ... </h:panelGroup>
You can use this from controller to stop ajax requests:
PrimeFaces.current().executeScript("PF('chkList').stop()"); //after Primefaces 7.0
or with older Primefaces version:
import org.primefaces.context.RequestContext;
...
RequestContext.getCurrentInstance().execute("PF('chkList').stop()"); //before Primefaces 7.0
Upvotes: 1
Reputation: 261
My solution:
<h:panelGroup id="chartPanel">
<h:graphicImage value="#{resource['img:loading.gif']}"
rendered="#{!indexController.chartReady}">
<p:poll interval="1" update="chartPanel" autoStart="true" />
</h:graphicImage>
<p:chart id="chart" type="line" model="#{indexController.chartModel}"
rendered="#{indexController.chartReady}" />
</h:panelGroup>
The polling is stopped when chartReady is true, no futher code in the bean
Upvotes: 0
Reputation: 848
this code works like a charm in my case:
<p:poll interval="2" update="flightsTable" widgetVar="poll"
autoStart="false" listener="#{searchFlightBean.checkIfSearchCompleate}"/>
Method in searchFlightBean:
public void checkIfSearchCompleate() {
if(searchCompleate) {
RequestContext reqCtx = RequestContext.getCurrentInstance();
reqCtx.execute("poll.stop();");
}
}
Upvotes: 7