use of com.google.gwt.user.client.rpc.AsyncCallback 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);
}
});
}
use of com.google.gwt.user.client.rpc.AsyncCallback 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);
}
});
}
use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.
the class SearchController method fetchSearchResults.
private void fetchSearchResults(String query) {
final SearchAllRequest input = ApiHelper.setAccessCode(new SearchAllRequest());
input.session = SessionController.get().sessionForApiCall();
input.query = query;
if (searchAllRequest != null) {
searchAllRequest.cancel();
}
searchAllRequest = ApiHelper.createSearchClient().searchAll(input, new AsyncCallback<SearchAllResponse>() {
@Override
public void onSuccess(SearchAllResponse output) {
searchAllRequest = null;
if (output.status == StatusType.StatusTypeSuccess) {
List<SearchResult> results = new ArrayList<SearchController.SearchResult>();
if (output.posts != null) {
for (Post post : output.posts) {
results.add(new SearchResult(post));
}
}
if (output.pages != null) {
for (Page page : output.pages) {
results.add(new SearchResult(page));
}
}
if (output.users != null) {
for (User user : output.users) {
results.add(new SearchResult(user));
}
}
updateRowCount(results.size(), true);
updateRowData(0, results);
}
DefaultEventBus.get().fireEventFromSource(new SearchAllSuccess(input, output), SearchController.this);
}
@Override
public void onFailure(Throwable caught) {
searchAllRequest = null;
DefaultEventBus.get().fireEventFromSource(new SearchAllFailure(input, caught), SearchController.this);
}
});
}
use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.
the class PropertyController method fetchProperties.
private void fetchProperties() {
final GetPropertiesRequest input = ApiHelper.setAccessCode(new GetPropertiesRequest());
input.pager = pager;
input.session = SessionController.get().sessionForApiCall();
if (getPropertiesRequest != null) {
getPropertiesRequest.cancel();
}
getPropertiesRequest = ApiHelper.createBlogClient().getProperties(input, new AsyncCallback<GetPropertiesResponse>() {
@Override
public void onSuccess(GetPropertiesResponse output) {
getPropertiesRequest = null;
if (output.status == StatusType.StatusTypeSuccess) {
if (output.properties != null && output.properties.size() > 0) {
pager = output.pager;
JsonArray propertyArray = new JsonArray();
for (Property p : output.properties) {
propertyArray.add(p.toJson());
}
Window.get().setProperties(propertyArray.toString());
}
}
DefaultEventBus.get().fireEventFromSource(new GetPropertiesSuccess(input, output), PropertyController.this);
}
@Override
public void onFailure(Throwable caught) {
getPropertiesRequest = null;
DefaultEventBus.get().fireEventFromSource(new GetPropertiesFailure(input, caught), PropertyController.this);
}
});
}
use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.
the class RoleController method fetchRoles.
private void fetchRoles() {
final GetRolesRequest input = ApiHelper.setAccessCode(new GetRolesRequest());
input.pager = pager;
input.session = SessionController.get().sessionForApiCall();
if (getRolesRequest != null) {
getRolesRequest.cancel();
}
getRolesRequest = ApiHelper.createUserClient().getRoles(input, new AsyncCallback<GetRolesResponse>() {
@Override
public void onSuccess(GetRolesResponse output) {
getRolesRequest = null;
if (output.status == StatusType.StatusTypeSuccess) {
if (output.roles != null && output.roles.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.roles);
} else {
updateRowCount(input.pager.start.intValue(), true);
updateRowData(input.pager.start.intValue(), Collections.<Role>emptyList());
}
}
DefaultEventBus.get().fireEventFromSource(new GetRolesSuccess(input, output), RoleController.this);
}
@Override
public void onFailure(Throwable caught) {
getRolesRequest = null;
DefaultEventBus.get().fireEventFromSource(new GetRolesFailure(input, caught), RoleController.this);
}
});
}
Aggregations