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());
}
});
}
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;
}
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;
}
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);
}
});
}
Aggregations