2016-03-31 22 views
0

我第一次使用CellTree並慢慢地掌握它。 現在我正在努力如何在單擊「顯示更多」文本旁邊顯示進度圖標(就像打開樹節點時一樣)。 任何想法? 我想這是一個普遍的問題,即如果用戶沒有得到任何視覺反饋 - 這會導致多個服務器調用和一堆重複節點(在我的情況下),他們多次單擊「Shore」多次。如何在CellTree上單擊「顯示更多」時顯示進度圖標?

回答

0

無論何時您將呼叫發送到服務器,您都知道您正在撥打電話。同樣,您將收到一個回撥到您的代碼,無論它成功或失敗。

對於這個例子的目的,我假設你正在使用類似GWT-RPC(因爲這個問題沒有指定):

// field to track if we're loading 
private boolean isLoading = false 

//... 

// inside a method which needs to load data: 
if (isLoading) { 
    return;//don't attempt to load again 
} 
isLoading = true; 
//just before we start the call, show the loading indicator 
loadingIndicator.flash();//or whatever you'd like to make it do 
//then start the request 
service.getMyData(param1, param2, new AsyncCallback<MyData>() { 
    public void onSuccess(MyData response) { 
    //loading was successful, so stop the loading marker 
    isLoading = false; 
    loadingIndicator.success(); 

    //do something with the data 
    //... 
    } 
    public void onFailure(Throwable ex) { 
    //loading stopped, but it was an error, tell the user 
    isLoading = false; 
    loadingIndicator.error(); 
    } 
});