Search in sources :

Example 1 with GetResourcesFailure

use of com.willshex.blogwt.client.api.blog.event.GetResourcesEventHandler.GetResourcesFailure in project blogwt by billy1380.

the class ResourceController method fetchResources.

private void fetchResources() {
    final GetResourcesRequest input = ApiHelper.setAccessCode(new GetResourcesRequest());
    input.pager = pager;
    input.session = SessionController.get().sessionForApiCall();
    if (getResourcesRequest != null) {
        getResourcesRequest.cancel();
    }
    getResourcesRequest = ApiHelper.createBlogClient().getResources(input, new AsyncCallback<GetResourcesResponse>() {

        @Override
        public void onSuccess(GetResourcesResponse output) {
            getResourcesRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
                if (output.resources != null && output.resources.size() > 0) {
                    pager = output.pager;
                    updateRowCount(input.pager.count == null ? 0 : input.pager.count.intValue(), input.pager.count == null || input.pager.count.intValue() == 0);
                    updateRowData(input.pager.start.intValue(), output.resources);
                } else {
                    updateRowCount(input.pager.start.intValue(), true);
                    updateRowData(input.pager.start.intValue(), Collections.<Resource>emptyList());
                }
            }
            DefaultEventBus.get().fireEventFromSource(new GetResourcesSuccess(input, output), ResourceController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            getResourcesRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetResourcesFailure(input, caught), ResourceController.this);
        }
    });
}
Also used : GetResourcesRequest(com.willshex.blogwt.shared.api.blog.call.GetResourcesRequest) GetResourcesSuccess(com.willshex.blogwt.client.api.blog.event.GetResourcesEventHandler.GetResourcesSuccess) GetResourcesFailure(com.willshex.blogwt.client.api.blog.event.GetResourcesEventHandler.GetResourcesFailure) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetResourcesResponse(com.willshex.blogwt.shared.api.blog.call.GetResourcesResponse)

Aggregations

AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 GetResourcesFailure (com.willshex.blogwt.client.api.blog.event.GetResourcesEventHandler.GetResourcesFailure)1 GetResourcesSuccess (com.willshex.blogwt.client.api.blog.event.GetResourcesEventHandler.GetResourcesSuccess)1 GetResourcesRequest (com.willshex.blogwt.shared.api.blog.call.GetResourcesRequest)1 GetResourcesResponse (com.willshex.blogwt.shared.api.blog.call.GetResourcesResponse)1