我想使用Primefaces为服务器端事件提供进度条。我的第一次尝试是将操作包含在也触发Ajax进度条的按钮中:
<p:commandButton value="Start" type="button" action="#{userAction.doWork}" onclick="PF('pbAjax').start();PF('startButton2').disable();" widgetVar="startButton2" />
<p:progressBar widgetVar="pbAjax" ajax="true" value="#{userAction.progress}" labelTemplate="{value}%" styleClass="animated" global="false">
<p:ajax event="complete" listener="#{userAction.onComplete}" update=":form" oncomplete="startButton2.enable()"/>
</p:progressBar>
这不起作用,因为没有调用UserAction.doWork。所以我的第二次尝试是提供一个ajax事件=“开始”:
<p:progressBar widgetVar="pbAjax" ajax="true" value="#{userAction.progress}" labelTemplate="{value}%" styleClass="animated" global="false">
<p:ajax event="start" listener="#{userAction.go}" />
<p:ajax event="complete" listener="#{userAction.onComplete}" update=":form" oncomplete="startButton2.enable()"/>
</p:progressBar>
这不起作用,因为我收到了“事件:不支持启动”。
有什么建议可以调用userAction.go方法??
答案 0 :(得分:0)
删除type="button"
即可。
<p:commandButton value="Start" action="#{userAction.doWork}" onclick="PF('pbAjax').start();PF('startButton2').disable();" widgetVar="startButton2" />