2012-07-18 2 views
1

이것이 가능한지 확실하지 않습니다. '제출'버튼을 클릭하면이 작업을 수행 할 수있는 것처럼 보입니다.Wicket - Progress/Multiple Label Updates

private Button getButton(String id) 
{ 
    return new AjaxButton(id) 
    { 
      private static final long serialVersionUID = 1L; 
      { 
       setEnabled(true); 
      } 

      @Override 
      protected void onSubmit(AjaxRequestTarget target, Form<?> form) 
      { 
       debug = "Beginning a process...."; 
       target.addComponent(debugLabel); 

       //Perform the first process 

       debug = "Beginning second process...."; 
       target.addComponent(debugLabel); 

       //Perform the second process 

       debug = "Finishing...."; 
       target.addComponent(debugLabel); 

       //Perform the third process 

       debug = "Done."; 
       target.addComponent(debugLabel); 
      } 
      @Override 
      protected void onError(AjaxRequestTarget target, Form form) 
      { 
       //NO-OP 
      } 
     }; 
    } 
} 

여러 개의 실시간 업데이트를 사용할 수 없다면 어떻게 할 수 있습니까? 하단에 상태 라벨이 표시되어 업데이트가 진행되는 과정을 알려줍니다.

답변

1

WebSocketBehavior 그냥, AjaxTimerBehavior를 사용하여 사용할 수 있습니다.

코드 :

add(new AbstractAjaxTimerBehavior(Duration.seconds(1)) 
     { 
      @Override 
      protected void onTimer(AjaxRequestTarget target) 
      { 
       target.add(label); 
      } 
     }); 

물론이 솔루션이 바보 AJAX 폴링을 사용하기 때문에 인트라넷 또는 다른 트래픽이 적은 사이트에 그것을 사용하는 유일한 것이 좋습니다.

2

다른 스레드에서 알림을 받고자하는 프로세스를 시작해야합니다. 그런 다음 레이블에 바인딩 된 일부 ajax Behavior에 의해 주기적으로 검사 될 상태에 대한 정보로 사용자 세션을 업데이트 할 수 있습니다.

개찰구 6 당신은 또한 모든 1 ~ 2 초가 레이블을 업데이트하도록

+0

죄송합니다. 나를 잃어 버렸습니다. 코드에 간단한 예제를 제공해 주시겠습니까? –

+0

나는 집에있을 때 (몇 시간 내에) 내가 제공 할 것이다. 어떤 개찰판 버전을 사용합니까? –

+0

그것에 대해 확실하지 않습니다. Eclipse에서 내 라이브러리 중 하나 인 wicket-1.4.17.jar를 참조합니다. –