单击&#34时显示进度图标的方法;显示更多"在CellTree上?

时间:2016-03-31 19:57:05

标签: gwt cell

我第一次使用CellTree并慢慢地使用它。 现在,我正在努力如何在"旁边显示进度图标(就像打开一个树节点一样);显示更多"点击它时的文字。 有任何想法吗? 我想这是用户点击的常见问题" Shore more"多次,如果他们没有得到任何视觉反馈 - 这导致多个服务器调用和一堆重复节点(在我的情况下)。

1 个答案:

答案 0 :(得分: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();
  }
});