2012-08-31 56 views
1

我正在使用素臉3.2。 Ajax輪詢不會停止,我正在使用停止屬性來停止輪詢,並且我正試圖用getter和setter來阻止它形成bean。 即使我已經使用Java腳本來停止,但我不能。任何停止投票的解決方案?在jsf primefaces中停止ajax輪詢?

+2

哇...你真的應該開始將答案標記爲「正確」以表示你以前的答案。 – SJuan76

+0

http://www.primefaces.org/showcase/ui/pollStartStop.jsf – Daniel

回答

5

此代碼的工作就像在我的情況下,魅力:

<p:poll interval="2" update="flightsTable" widgetVar="poll" 
     autoStart="false" listener="#{searchFlightBean.checkIfSearchCompleate}"/> 

方法searchFlightBean:

public void checkIfSearchCompleate() { 
    if(searchCompleate) { 
     RequestContext reqCtx = RequestContext.getCurrentInstance(); 
     reqCtx.execute("poll.stop();"); 
    } 
} 
+0

民意調查將停止。但在螢火蟲我可以看到呼叫running.it停止頁面刷新後只有 – wild

+0

我怎麼能阻止它 – wild

0

我的解決辦法:

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

輪詢停止時chartReady是真實的,沒有進一步的代碼在豆