Search in sources :

Example 1 with GetPagesFailure

use of com.willshex.blogwt.client.api.page.event.GetPagesEventHandler.GetPagesFailure in project blogwt by billy1380.

the class PageController method fetchPages.

private void fetchPages() {
    final GetPagesRequest input = ApiHelper.setAccessCode(new GetPagesRequest());
    input.pager = pager;
    input.session = SessionController.get().sessionForApiCall();
    input.includePosts = Boolean.FALSE;
    if (getPagesRequest != null) {
        getPagesRequest.cancel();
    }
    getPagesRequest = ApiHelper.createPageClient().getPages(input, new AsyncCallback<GetPagesResponse>() {

        @Override
        public void onSuccess(GetPagesResponse output) {
            getPagesRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
                if (output.pages != null && output.pages.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.pages);
                } else {
                    updateRowCount(input.pager.start.intValue(), true);
                    updateRowData(input.pager.start.intValue(), Collections.<Page>emptyList());
                }
            }
            DefaultEventBus.get().fireEventFromSource(new GetPagesSuccess(input, output), PageController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            getPagesRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetPagesFailure(input, caught), PageController.this);
        }
    });
}
Also used : GetPagesRequest(com.willshex.blogwt.shared.api.page.call.GetPagesRequest) GetPagesFailure(com.willshex.blogwt.client.api.page.event.GetPagesEventHandler.GetPagesFailure) GetPagesSuccess(com.willshex.blogwt.client.api.page.event.GetPagesEventHandler.GetPagesSuccess) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetPagesResponse(com.willshex.blogwt.shared.api.page.call.GetPagesResponse)

Aggregations

AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 GetPagesFailure (com.willshex.blogwt.client.api.page.event.GetPagesEventHandler.GetPagesFailure)1 GetPagesSuccess (com.willshex.blogwt.client.api.page.event.GetPagesEventHandler.GetPagesSuccess)1 GetPagesRequest (com.willshex.blogwt.shared.api.page.call.GetPagesRequest)1 GetPagesResponse (com.willshex.blogwt.shared.api.page.call.GetPagesResponse)1