2013-10-11 1 views

답변

2

PrimeFaces의 사용 <p:progressBar/>. 그들은 showcase에 클라이언트 측, 아약스 및 정적 버전의 예가 있습니다.

아약스 버전은 특정 동작 (예에서 commandButton 클릭)에서 진행률 표시 줄 시작으로 이어집니다. 100 %에 도달하면 자동으로 (아약스 이벤트가 필요한 경우 문서를 참조 후 해고) 중지됩니다 쇼케이스의

관련 XHTML과 빈 부분은 (거의) 그대로

XHTML

에게 복사
<p:progressBar widgetVar="pbAjax" ajax="true" value="#{progressBarView.progress}" labelTemplate="{value}%" styleClass="animated" global="false"> 
    <p:ajax event="complete" listener="#{progressBarView.onComplete}" update="growl" oncomplete="PF('startButton2').enable()"/> 
</p:progressBar> 

@Named 
@ViewScoped 
public class ProgressBarView 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() { 
     FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Progress Completed")); 
    } 
} 

PF 쇼케이스의 예에서는 취소 할 수도 있지만 실제 서버 측 작업 취소는 여기에 있으므로 범위를 벗어납니다.

+0

링크가 끊어졌습니다. 이것을 업데이트 할 수 있습니까? – 16num

+1

@ 16num : PF 쇼케이스에 대한 예제가 있습니다. 찾기 쉽습니다. (그리고 편집 버튼을 눌러 편집을 제안 할 수 있습니다.) 그리고 이것은 특히 '링크 만 응답'이 강하게 권장되지 않는 이유입니다 – Kukeltje

관련 문제