use of com.willshex.blogwt.client.api.search.event.SearchAllEventHandler.SearchAllSuccess 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