Saturday, October 26, 2013

What is the simplest way to show “loading indicator” during an RPC call in GWTP?

I am using GWTP to build my webapp. Here is my problem. I have a customer page (CustPresenter). When that page is visited, it will call & load Data from Database.

It may take a while to load all data, so I want my current Browser locked so that the user can not click any things while data has not finished downloading yet.

So here is what I am thinking. I want to show a DialogBox right before I make the RPC call & hide it when the call finishes. Look at the below code:

public class CustPresenter extends      Presenter<CustPresenter.MyView, CustPresenter.MyProxy> {        private DialogBox loadingDialogBox=new DialogBox();        @Inject DispatchAsync dispatchAsync;        @Override      public void prepareFromRequest(PlaceRequest request){           super.prepareFromRequest(request);           loadingDialogBox.show();           GetData getDataAction=new GetData();           dispatchAsync.execute(getDataAction, getDataCallback);        }        private AsyncCallback<GetDataResult> getDataCallback=new AsyncCallback<GetDataResult>(){            @Override          public void onFailure(Throwable caught) {              loadingDialogBox.hide();          }            @Override          public void onSuccess(GetVerbFromTripleResult result) {               //show data here (it may take long time)               loadingDialogBox.hide();          }     };  }  

However, when runing, the dialogbox only shows up for 1 second & then disappears. Right After that all the UiBinder Guis show up on the Customer Page & user can click any buttons on the page while the data has not finished downloading yet. This is not a correct behavior.

I want to do something like this http://sqlfiddle.com/#!2/a2581/1. As u can see, when u first time open that link, a loading panel popups & u can't click anything until all guis show up.

So, why do I have this problem?

How to fix it?

Or generally, What is the simplest way to show "loading indicator" during an RPC call in GWTP?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment