use of com.willshex.blogwt.client.api.blog.event.GetPostsEventHandler.GetPostsSuccess in project blogwt by billy1380.
the class PostController method fetchPosts.
private void fetchPosts() {
final GetPostsRequest input = ApiHelper.setAccessCode(new GetPostsRequest());
input.session = SessionController.get().sessionForApiCall();
input.includePostContents = Boolean.FALSE;
input.archiveEntry = archiveEntry;
input.showAll = Boolean.valueOf(isAdminMode);
if (SessionController.get().isValidSession()) {
pager.sortBy = PostSortType.PostSortTypeCreated.toString();
} else {
pager.sortBy = PostSortType.PostSortTypePublished.toString();
}
input.pager = pager;
input.tag = tag;
if (getPostsRequest != null) {
getPostsRequest.cancel();
}
getPostsRequest = ApiHelper.createBlogClient().getPosts(input, new AsyncCallback<GetPostsResponse>() {
@Override
public void onSuccess(GetPostsResponse output) {
getPostsRequest = null;
if (output.status == StatusType.StatusTypeSuccess) {
if (output.posts != null && output.posts.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.posts);
} else {
updateRowCount(input.pager.start.intValue(), true);
updateRowData(input.pager.start.intValue(), Collections.<Post>emptyList());
}
}
DefaultEventBus.get().fireEventFromSource(new GetPostsSuccess(input, output), PostController.this);
}
@Override
public void onFailure(Throwable caught) {
getPostsRequest = null;
DefaultEventBus.get().fireEventFromSource(new GetPostsFailure(input, caught), PostController.this);
}
});
}
Aggregations