Search in sources :

Example 1 with GetPageResponse

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

the class PageController method getPage.

/**
 * @param page
 */
public void getPage(Page page, boolean includePosts) {
    final GetPageRequest input = ApiHelper.setAccessCode(new GetPageRequest());
    input.session = SessionController.get().sessionForApiCall();
    input.page = page;
    input.includePosts = Boolean.valueOf(includePosts);
    if (getPageRequest != null) {
        getPageRequest.cancel();
    }
    getPageRequest = ApiHelper.createPageClient().getPage(input, new AsyncCallback<GetPageResponse>() {

        @Override
        public void onSuccess(GetPageResponse output) {
            getPageRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
            }
            DefaultEventBus.get().fireEventFromSource(new GetPageSuccess(input, output), PageController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            getPageRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetPageFailure(input, caught), PageController.this);
        }
    });
}
Also used : GetPageSuccess(com.willshex.blogwt.client.api.page.event.GetPageEventHandler.GetPageSuccess) GetPageResponse(com.willshex.blogwt.shared.api.page.call.GetPageResponse) GetPageFailure(com.willshex.blogwt.client.api.page.event.GetPageEventHandler.GetPageFailure) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetPageRequest(com.willshex.blogwt.shared.api.page.call.GetPageRequest)

Example 2 with GetPageResponse

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

the class PageService method getPage.

public Request getPage(GetPageRequest input, AsyncSuccess<GetPageRequest, GetPageResponse> onSuccess, AsyncFailure<GetPageRequest> onFailure) {
    Request handle = null;
    try {
        handle = sendRequest(PageMethodGetPage, input, new RequestCallback() {

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

            @Override
            public void onError(Request request, Throwable exception) {
                if (onFailure != null) {
                    onFailure.call(input, exception);
                }
                onCallFailure(PageService.this, PageMethodGetPage, input, exception);
            }
        });
        onCallStart(PageService.this, PageMethodGetPage, input, handle);
    } catch (RequestException exception) {
        if (onFailure != null) {
            onFailure.call(input, exception);
        }
        onCallFailure(PageService.this, PageMethodGetPage, 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) GetPageResponse(com.willshex.blogwt.shared.api.page.call.GetPageResponse) 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) RequestException(com.google.gwt.http.client.RequestException)

Aggregations

GetPageRequest (com.willshex.blogwt.shared.api.page.call.GetPageRequest)2 GetPageResponse (com.willshex.blogwt.shared.api.page.call.GetPageResponse)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 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 GetPageFailure (com.willshex.blogwt.client.api.page.event.GetPageEventHandler.GetPageFailure)1 GetPageSuccess (com.willshex.blogwt.client.api.page.event.GetPageEventHandler.GetPageSuccess)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 GetPagesRequest (com.willshex.blogwt.shared.api.page.call.GetPagesRequest)1 GetPagesResponse (com.willshex.blogwt.shared.api.page.call.GetPagesResponse)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