我是最新的primefaces。我想要做的是填充h:outputText,但我必须使用p:poll,因为我提出了一个请求,我必须等待响应,并且可能需要一些时间才能得到答案。一个p:投票停止另一个?
<h:form id="form1">
<p:poll widgetVar="headerPoll" interval="3" listener="#{bean.refreshHeader()}" update="form1" />
</h:form>
<h:form id="bodyForm">
<p:commandButton actionListener = "#{bean.loadBody}" ajax="false" value="load body" /> <br/><br/>
<h:outputText id="bodyText" escape="false" value="#{bean.body}" />
<p:poll widgetVar="bodyPoll" interval="3" listener="#{bean.refreshBody()}" update="bodyText" />
</h:form>
相关的豆:
public void refreshHeader()
{
if(header != null)
{
RequestContext reqCtx = RequestContext.getCurrentInstance();
reqCtx.execute("headerPoll.stop();");
}
}
public void refreshBody()
{
if(body != null)
{
RequestContext reqCtx = RequestContext.getCurrentInstance();
reqCtx.execute("bodyPoll.stop();");
}
}
的问题是在refreshHeader()
功能。当headerPoll.stop()
得到执行时,停止第一轮和第二轮轮询。我只需要停止一个。
我该如何停止其中一项调查?
您使用的是哪个版本的PF? – 2014-09-25 13:15:04
你必须注意,你有一个按钮是ajax =“false”,会影响你的民意调查....我测试了你的代码,它对我来说工作得很好。 – 2014-09-25 13:27:06
你可以“停止”(使渲染属性为false)停止行为。 – Cold 2014-09-25 13:37:05