Saturday, October 26, 2013

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

I found a cool solution, that is we have to use WidgetPresenter with PopupPanel (say LoadingPresenter). So in my Custom AsyncCall class, i need to fire loadingPresenter. It won't work if we use PopupPanel class inside AsyncCall, i don't understand why? but work if we use PopupPanel Presenter widget

public abstract class AsyncCall<T> implements AsyncCallback<T> {


    /** Call the service method using cb as the callback. */
    public AsyncCall()
    {
        Utility.eventBus.fireEvent(new ShowLoadingEvent(true));
    }

    public final void onFailure(Throwable caught) 
    {    
        //myp.hide();
        Utility.eventBus.fireEvent(new ShowLoadingEvent(false));
        onCustomFailure(caught); 
    } 

    public final void onSuccess(T result) 
    {       
        //myp.hide(); 
        Utility.eventBus.fireEvent(new ShowLoadingEvent(false));
        onCustomSuccess(result);     
    }
    /** the failure method needed to be overwritte */   
    protected abstract void onCustomFailure(Throwable caught);  

    /** overwritte to do something with result */
    protected abstract void onCustomSuccess(T result); 

}

To make RPC Call, simple use this:

  private AsyncCall<GetDataResult> getDataCallback=new AsyncCall<GetDataResult>(){

        @Override
        public void onCustomFailure(Throwable caught) {

        }

        @Override
        public void onCustomSuccess(GetVerbFromTripleResult result) {
             //show data here (it may take long time)

        }
   };

and then it run really smoothly.


On Saturday, October 26, 2013 8:21:57 PM UTC+11, Tom wrote:

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