use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.
the class PageController method getPage.
/**
* @param page
*/
public void getPage(Page page, boolean includePosts) {
final GetPageRequest input = ApiHelper.setAccessCode(new GetPageRequest());
input.session = SessionController.get().sessionForApiCall();
input.page = page;
input.includePosts = Boolean.valueOf(includePosts);
if (getPageRequest != null) {
getPageRequest.cancel();
}
getPageRequest = ApiHelper.createPageClient().getPage(input, new AsyncCallback<GetPageResponse>() {
@Override
public void onSuccess(GetPageResponse output) {
getPageRequest = null;
if (output.status == StatusType.StatusTypeSuccess) {
}
DefaultEventBus.get().fireEventFromSource(new GetPageSuccess(input, output), PageController.this);
}
@Override
public void onFailure(Throwable caught) {
getPageRequest = null;
DefaultEventBus.get().fireEventFromSource(new GetPageFailure(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 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);
}
});
}
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);
}
});
}
Aggregations