2

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?

SJuan76
  • 24,532
  • 6
  • 47
  • 87
wild
  • 169
  • 1
  • 3
  • 19

3 Answers3

6

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();");
    }
}
Danny.
  • 363
  • 1
  • 4
  • 23
Misha
  • 828
  • 10
  • 23
1
<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
martoni
  • 11
  • 3
0

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

Nolle
  • 201
  • 2
  • 5