jsf - p:poll 已停止但仍会触发网络调用
问题描述
我必须使用某些条件停止并p:poll
在 JSF 中启动...我可以通过将民意调查放入 panelgrid 并渲染 panelGrid 来做到这一点...我认为它可以工作,因为 pollOperationStatus 在我制作之后没有被调用panelGrid 呈现错误...当我显示它时,它也会重新启动..但是仍然有一个网络调用;这搞砸了很多事情;如何处理?
<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>
解决方案
可以使用客户端 api 启动和停止轮询;或者将布尔变量绑定到
stop
属性并在任意时间将其设置为 false。
在您的情况下,这将是javaScript
:
PF('poller').stop();
或者PF('poller').start();
或者绑定一个boolean
bean属性的stop
属性p:poll
:
<p:poll stop="#{myBean.stopPoller}" interval="8" widgetVar="poller" autoStart="true"
listener="#{myBean.pollOperationStatus}"
update=":#{p:component('newServerID')} :#{p:component('mypollform')}" />
另请注意,update
属性中的组件 ID 由空格分隔,而不是逗号。
推荐阅读
- javascript - 无法在按钮单击时根据 localStorage 更改文本语言
- c++ - 如何应对无限可能的结果?
- python - 抓取页面时内部循环重复太多次。每页约4-5次
- jquery-ajaxq - JQuery AJAX 调用成功,但响应未定义
- java - 运行 Windows Nanoserver 的 Docker 容器中的 Spring Boot InetAddress 问题
- c# - 在两个角度之间实例化的多个游戏对象
- python - 使用 Scipy Stats 的对数均匀分布
- python - Kivy Label 添加文本而不重叠
- java - Android - 不同屏幕尺寸的 animate() 问题
- python - 如何在 Python 中从 azure 服务队列中查看 c 消息