jsf - p:accordionPanel 在第一个选项卡上进行投票
问题描述
<p:poll>
我默认禁用autoStart="false"
.
现在我有一个由 commandButton 打开的对话框,其中包含以下示例代码:
<h:body>
<h:form>
<p:commandButton value="Open Dialog" oncomplete="PF('sampleDialog').show();PF('w_poll').start();"/>
<p:dialog header="Sample Dialog" height="300" width="400" widgetVar="sampleDialog" resizable="false" onHide="PF('w_poll').stop();">
<p:accordionPanel>
<p:ajax event="tabChange" oncomplete="PF('w_poll').start();"/>
<p:tab title="First">
<h:panelGroup id="firstGroup">
<p:poll interval="1"
id="firstPoll"
widgetVar="w_poll"
update="firstLabel"
async="true"
autoStart="false"
global="false"
listener="#{firstCounter.init}"/>
<p:outputLabel value="#{firstCounter.number}" id="firstLabel"/>
</h:panelGroup>
</p:tab>
<p:tab title="Second">
<h:panelGroup id="secondGroup">
<p:poll interval="3"
id="secondPoll"
widgetVar="w_poll"
update="secondLabel"
async="true"
autoStart="false"
global="false"
listener="#{secondCounter.init}"/>
<p:outputLabel value="#{secondCounter.number}" id="secondLabel"/>
</h:panelGroup>
</p:tab>
<p:tab title="Third">
<h:panelGroup id="thirdGroup">
<p:poll interval="5"
id="thirdPoll"
widgetVar="w_poll"
update="thirdLabel"
async="true"
autoStart="false"
global="false"
listener="#{thirdCounter.init}"/>
<p:outputLabel value="#{thirdCounter.number}" id="thirdLabel"/>
</h:panelGroup>
</p:tab>
</p:accordionPanel>
</p:dialog>
</h:form>
</h:body>
注意:您可以看到民意调查在对话框显示开始并在隐藏时停止。
这是我的豆子:
public abstract class AbstractBean implements Serializable {
private int number;
public void counter(int sleepTime) {
sleep(sleepTime);
this.number = number + 1;
}
public int getNumber() {
return number;
}
private static void sleep(int time) {
try {
Thread.sleep(time);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
现在用这个抽象实现三个bean:
@Named
@ViewScoped
public class FirstCounter extends AbstractBean {
@PostConstruct
public void init() {
counter(1000);
}
}
另一个:
@Named
@ViewScoped
public class SecondCounter extends AbstractBean {
@PostConstruct
public void init() {
counter(3000);
}
}
另一个:
@Named
@ViewScoped
public class ThirdCounter extends AbstractBean {
@PostConstruct
public void init() {
counter(5000);
}
}
我有两个问题:
1)打开对话框后手风琴面板的第一个选项卡没有启动计数器。
2)更改选项卡事件不起作用。我想启动同一个选项卡的计数器。
解决方案
推荐阅读
- javascript - 谷歌地图自动完成在模式弹出窗口中不起作用
- vb.net - INSERT INTO 语句中的语法错误。
- java - 使用 java 创建 aws 参数化管道
- java - 仅使用 JDK Api 将 SOAP 消息写入标准输出
- android - 切换片段时阻止谷歌地图重新加载
- css - MS Edge 未在 unicode 符号上应用 css 样式“颜色”
- docker - 在搬运工中修改 docker 镜像
- go - 为什么在解组后我得到不同的字节数但在编组后得到相同的结果?
- objective-c - 如何将以下有关 Core Graphics 的代码转换为 Swift?
- tfs - 如何知道当前的变更集 id TFS Visual Studio