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