Search in sources :

Example 1 with GetPagesRequest

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

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

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

the class PageJsonServlet method processAction.

@Override
protected String processAction(String action, JsonObject request) {
    String output = "null";
    if ("SubmitForm".equals(action)) {
        SubmitFormRequest input = new SubmitFormRequest();
        input.fromJson(request);
        output = new SubmitFormActionHandler().handle(input).toString();
    } else if ("GetPages".equals(action)) {
        GetPagesRequest input = new GetPagesRequest();
        input.fromJson(request);
        output = new GetPagesActionHandler().handle(input).toString();
    } else if ("GetPage".equals(action)) {
        GetPageRequest input = new GetPageRequest();
        input.fromJson(request);
        output = new GetPageActionHandler().handle(input).toString();
    } else if ("UpdatePage".equals(action)) {
        UpdatePageRequest input = new UpdatePageRequest();
        input.fromJson(request);
        output = new UpdatePageActionHandler().handle(input).toString();
    } else if ("DeletePage".equals(action)) {
        DeletePageRequest input = new DeletePageRequest();
        input.fromJson(request);
        output = new DeletePageActionHandler().handle(input).toString();
    } else if ("CreatePage".equals(action)) {
        CreatePageRequest input = new CreatePageRequest();
        input.fromJson(request);
        output = new CreatePageActionHandler().handle(input).toString();
    }
    return output;
}
Also used : GetPagesRequest(com.willshex.blogwt.shared.api.page.call.GetPagesRequest) DeletePageActionHandler(com.willshex.blogwt.server.api.page.action.DeletePageActionHandler) UpdatePageActionHandler(com.willshex.blogwt.server.api.page.action.UpdatePageActionHandler) CreatePageRequest(com.willshex.blogwt.shared.api.page.call.CreatePageRequest) CreatePageActionHandler(com.willshex.blogwt.server.api.page.action.CreatePageActionHandler) UpdatePageRequest(com.willshex.blogwt.shared.api.page.call.UpdatePageRequest) GetPageRequest(com.willshex.blogwt.shared.api.page.call.GetPageRequest) GetPageActionHandler(com.willshex.blogwt.server.api.page.action.GetPageActionHandler) DeletePageRequest(com.willshex.blogwt.shared.api.page.call.DeletePageRequest) SubmitFormRequest(com.willshex.blogwt.shared.api.page.call.SubmitFormRequest) SubmitFormActionHandler(com.willshex.blogwt.server.api.page.action.SubmitFormActionHandler) GetPagesActionHandler(com.willshex.blogwt.server.api.page.action.GetPagesActionHandler)

Example 4 with GetPagesRequest

use of com.willshex.blogwt.shared.api.page.call.GetPagesRequest 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)4 GetPagesResponse (com.willshex.blogwt.shared.api.page.call.GetPagesResponse)3 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)2 CreatePageRequest (com.willshex.blogwt.shared.api.page.call.CreatePageRequest)2 DeletePageRequest (com.willshex.blogwt.shared.api.page.call.DeletePageRequest)2 GetPageRequest (com.willshex.blogwt.shared.api.page.call.GetPageRequest)2 SubmitFormRequest (com.willshex.blogwt.shared.api.page.call.SubmitFormRequest)2 UpdatePageRequest (com.willshex.blogwt.shared.api.page.call.UpdatePageRequest)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 CreatePageActionHandler (com.willshex.blogwt.server.api.page.action.CreatePageActionHandler)1 DeletePageActionHandler (com.willshex.blogwt.server.api.page.action.DeletePageActionHandler)1 GetPageActionHandler (com.willshex.blogwt.server.api.page.action.GetPageActionHandler)1 GetPagesActionHandler (com.willshex.blogwt.server.api.page.action.GetPagesActionHandler)1 SubmitFormActionHandler (com.willshex.blogwt.server.api.page.action.SubmitFormActionHandler)1