2017-02-19 4 views
0

クライアントがサーバー上でjsonを送信するときに、ロードウィジェットを表示するにはどうすればよいですか。 Resty-GWTの読み込み

それは要求を送信したとき、私は、このような方法

私はロードresty-GWTに表示するにはどうすればよい
/** 
* We display a short lock message whenever navigation is in progress. 
* 
* @param event The {@link LockInteractionEvent}. 
*/ 
@ProxyEvent 
public void onLockInteraction(LockInteractionEvent event) { 
getView().setLoading(event.shouldLock()); 
} 

を見つけexmaple GWTPの例から? onLockInteractionとresty-gwtを併用できますか?

+1

GWTPについてはわかりませんが、http://stackoverflow.com/a/38392507/5612847が役に立ちます。 –

答えて

1

RestyGWTカスタムDispatcherを使用して、要求ライフサイクルを追跡できます。 Dispatcherは、手動で、または注釈(https://resty-gwt.github.io/documentation/restygwt-user-guide.html)を使用して構成できます。例手動で設定する:

RootRestService rest = GWT.create(RootRestService.class); 
((RestServiceProxy) rest).setDispatcher(new DefaultDispatcher() { 
    @Override public Request send(Method m, RequestBuilder rb) throws RequestException { 
     RequestCallback callback = rb.getCallback(); 
     rb.setCallback(new RequestCallback() { 
      @Override public void onResponseReceived(Request req, Response res) { 
       log.info("request success (stop event)"); 
       callback.onResponseReceived(req, res); 
      } 
      @Override public void onError(Request req, Throwable ex) { 
       log.info("request error (stop event)"); 
       callback.onError(req, ex); 
      } 
     }); 
     try { 
      log.info("request initialized (start event)"); 
      return request = super.send(m, rb); 
     } finally { 
      log.info("request fail to initialize error (stop event)"); 
     } 
    } 
}); 

を代わりに、ロギングの、あなたがeventBusを使用してイベントを送信し、アクティブな要求の数を追跡するために、このイベントを使用し、最後にアクティブな多数の場合は負荷インジケータを表示することができますリクエストは0より大きいです。

+0

イベントをどのように呼び出すことができますか?私はここにプレゼンターを持っていません – LeshaRB

+0

あなたのアーキテクチャにもよりますが、静的変数を使用してeventBusを共有することはできます。 Ginを使用すると、RootRestServiceプロバイダを作成し、引数としてeventBusを追加できます。 –

関連する問題