Search in sources :

Example 1 with GetPagesResponse

use of com.willshex.blogwt.shared.api.page.call.GetPagesResponse in project blogwt by billy1380.

the class PageOracle method lookup.

/* (non-Javadoc)
	 * 
	 * @see
	 * com.willshex.blogwt.client.oracle.SuggestOracle#lookup(com.google.gwt
	 * .user.client.ui.SuggestOracle.Request,
	 * com.google.gwt.user.client.ui.SuggestOracle.Callback) */
@Override
protected void lookup(final Request request, final Callback callback) {
    final GetPagesRequest input = ApiHelper.setAccessCode(new GetPagesRequest());
    input.session = SessionController.get().sessionForApiCall();
    input.includePosts = Boolean.FALSE;
    input.query = request.getQuery();
    input.pager = PagerHelper.createDefaultPager();
    input.pager.count = Integer.valueOf(request.getLimit());
    if (getPagesRequest != null) {
        getPagesRequest.cancel();
    }
    getPagesRequest = ApiHelper.createPageClient().getPages(input, new AsyncCallback<GetPagesResponse>() {

        @Override
        public void onSuccess(GetPagesResponse output) {
            if (output.status == StatusType.StatusTypeSuccess && output.pager != null) {
                foundItems(request, callback, output.pages);
            } else {
                foundItems(request, callback, Collections.<Page>emptyList());
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            GWT.log("Error getting pages with query " + input.query, caught);
            foundItems(request, callback, Collections.<Page>emptyList());
        }
    });
}
Also used : GetPagesRequest(com.willshex.blogwt.shared.api.page.call.GetPagesRequest) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetPagesResponse(com.willshex.blogwt.shared.api.page.call.GetPagesResponse)

Example 2 with GetPagesResponse

use of com.willshex.blogwt.shared.api.page.call.GetPagesResponse in project blogwt by billy1380.

the class PageService method getPages.

public Request getPages(GetPagesRequest input, AsyncSuccess<GetPagesRequest, GetPagesResponse> onSuccess, AsyncFailure<GetPagesRequest> onFailure) {
    Request handle = null;
    try {
        handle = sendRequest(PageMethodGetPages, input, new RequestCallback() {

            @Override
            public void onResponseReceived(Request request, Response response) {
                try {
                    GetPagesResponse outputParameter = new GetPagesResponse();
                    parseResponse(response, outputParameter);
                    if (onSuccess != null) {
                        onSuccess.call(input, outputParameter);
                    }
                    onCallSuccess(PageService.this, PageMethodGetPages, input, outputParameter);
                } catch (JSONException | HttpException exception) {
                    if (onFailure != null) {
                        onFailure.call(input, exception);
                    }
                    onCallFailure(PageService.this, PageMethodGetPages, input, exception);
                }
            }

            @Override
            public void onError(Request request, Throwable exception) {
                if (onFailure != null) {
                    onFailure.call(input, exception);
                }
                onCallFailure(PageService.this, PageMethodGetPages, input, exception);
            }
        });
        onCallStart(PageService.this, PageMethodGetPages, input, handle);
    } catch (RequestException exception) {
        if (onFailure != null) {
            onFailure.call(input, exception);
        }
        onCallFailure(PageService.this, PageMethodGetPages, input, exception);
    }
    return handle;
}
Also used : GetPagesResponse(com.willshex.blogwt.shared.api.page.call.GetPagesResponse) UpdatePageResponse(com.willshex.blogwt.shared.api.page.call.UpdatePageResponse) SubmitFormResponse(com.willshex.blogwt.shared.api.page.call.SubmitFormResponse) CreatePageResponse(com.willshex.blogwt.shared.api.page.call.CreatePageResponse) GetPageResponse(com.willshex.blogwt.shared.api.page.call.GetPageResponse) Response(com.google.gwt.http.client.Response) DeletePageResponse(com.willshex.blogwt.shared.api.page.call.DeletePageResponse) RequestCallback(com.google.gwt.http.client.RequestCallback) GetPageRequest(com.willshex.blogwt.shared.api.page.call.GetPageRequest) CreatePageRequest(com.willshex.blogwt.shared.api.page.call.CreatePageRequest) Request(com.google.gwt.http.client.Request) GetPagesRequest(com.willshex.blogwt.shared.api.page.call.GetPagesRequest) SubmitFormRequest(com.willshex.blogwt.shared.api.page.call.SubmitFormRequest) DeletePageRequest(com.willshex.blogwt.shared.api.page.call.DeletePageRequest) UpdatePageRequest(com.willshex.blogwt.shared.api.page.call.UpdatePageRequest) JSONException(com.google.gwt.json.client.JSONException) HttpException(com.willshex.gson.web.service.client.HttpException) GetPagesResponse(com.willshex.blogwt.shared.api.page.call.GetPagesResponse) RequestException(com.google.gwt.http.client.RequestException)

Example 3 with GetPagesResponse

use of com.willshex.blogwt.shared.api.page.call.GetPagesResponse 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

GetPagesRequest (com.willshex.blogwt.shared.api.page.call.GetPagesRequest)3 GetPagesResponse (com.willshex.blogwt.shared.api.page.call.GetPagesResponse)3 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)2 Request (com.google.gwt.http.client.Request)1 RequestCallback (com.google.gwt.http.client.RequestCallback)1 RequestException (com.google.gwt.http.client.RequestException)1 Response (com.google.gwt.http.client.Response)1 JSONException (com.google.gwt.json.client.JSONException)1 GetPagesFailure (com.willshex.blogwt.client.api.page.event.GetPagesEventHandler.GetPagesFailure)1 GetPagesSuccess (com.willshex.blogwt.client.api.page.event.GetPagesEventHandler.GetPagesSuccess)1 CreatePageRequest (com.willshex.blogwt.shared.api.page.call.CreatePageRequest)1 CreatePageResponse (com.willshex.blogwt.shared.api.page.call.CreatePageResponse)1 DeletePageRequest (com.willshex.blogwt.shared.api.page.call.DeletePageRequest)1 DeletePageResponse (com.willshex.blogwt.shared.api.page.call.DeletePageResponse)1 GetPageRequest (com.willshex.blogwt.shared.api.page.call.GetPageRequest)1 GetPageResponse (com.willshex.blogwt.shared.api.page.call.GetPageResponse)1 SubmitFormRequest (com.willshex.blogwt.shared.api.page.call.SubmitFormRequest)1 SubmitFormResponse (com.willshex.blogwt.shared.api.page.call.SubmitFormResponse)1 UpdatePageRequest (com.willshex.blogwt.shared.api.page.call.UpdatePageRequest)1 UpdatePageResponse (com.willshex.blogwt.shared.api.page.call.UpdatePageResponse)1