如果有人能给我一些关于进度条和ajax后端处理的提示,我将不胜感激.
澄清我需要遵循的细节:
我有一个命令按钮在后端进行一些处理.我想在支持bean完成处理后端指令时显示一个达到100%的进度条.我看了很多线程,但没有运气.他们中的大多数都没有展示具体的样本如何做到这一点.以下是我的代码片段:
</h:panelGrid>
<p:commandButton id="btn" value="DoSomeAction"
styleClass="ui-priority-primary" update="panel"
onclick="PF('pbAjax').start();PF('startButton1').disable();"
widgetVar="startButton1"
actionListener="#{actionBean.DoSomeAction}" />
<p:progressBar widgetVar="pbAjax" ajax="true"
value="#{progressBean.progress}" labelTemplate="{value}%"
styleClass="animated">
<p:ajax event="complete" listener="#{progressBean.onComplete}"
update="growl" oncomplete="startButton2.enable()" />
</p:progressBar>
</p:panel>
Run Code Online (Sandbox Code Playgroud)
这是Progress Brean的代码:
@ManagedBean(name="progressBean")
public class ProgressBean implements Serializable {
private Integer progress;
public Integer getProgress() {
if(progress == null)
progress = 0;
else {
progress = progress + (int)(Math.random() * 35);
if(progress > 100)
progress = 100;
}
return progress;
}
public void setProgress(Integer progress) {
this.progress = progress;
}
public void onComplete() …Run Code Online (Sandbox Code Playgroud)