Example usage for com.google.gwt.http.client RequestCallbackWithProgress RequestCallbackWithProgress

List of usage examples for com.google.gwt.http.client RequestCallbackWithProgress RequestCallbackWithProgress

Introduction

In this page you can find the example usage for com.google.gwt.http.client RequestCallbackWithProgress RequestCallbackWithProgress.

Prototype

RequestCallbackWithProgress

Source Link

Usage

From source file:org.turbogwt.net.http.client.RequestImpl.java

License:Apache License

private <D> RequestCallback createRequestCallback(final DeferredRequest<D> deferred) {
    return new RequestCallbackWithProgress() {
        @Override//from   w w  w. j  a  va 2 s.  c o m
        public void onResponseReceived(Request request, Response response) {
            // Execute filters on this response
            final List<ResponseFilter> filters = filterManager.getResponseFilters();
            for (ResponseFilter filter : filters) {
                filter.filter(response);
            }

            if (response.getStatusCode() / 100 == 2) {
                deferred.resolve(response);
            } else {
                deferred.reject(response);
            }
        }

        @Override
        public void onProgress(RequestProgress requestProgress) {
            deferred.notify(new RequestProgressImpl(requestProgress));
        }

        @Override
        public void onError(Request request, Throwable exception) {
            deferred.reject(exception);
        }
    };
}