use of com.willshex.blogwt.shared.api.user.call.GetUsersResponse in project blogwt by billy1380.
the class UserController method fetchUsers.
private void fetchUsers() {
final GetUsersRequest input = ApiHelper.setAccessCode(new GetUsersRequest());
input.pager = pager;
input.session = SessionController.get().sessionForApiCall();
if (getUsersRequest != null) {
getUsersRequest.cancel();
}
getUsersRequest = ApiHelper.createUserClient().getUsers(input, new AsyncCallback<GetUsersResponse>() {
@Override
public void onSuccess(GetUsersResponse output) {
getUsersRequest = null;
if (output.status == StatusType.StatusTypeSuccess) {
if (output.users != null && output.users.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.users);
} else {
updateRowCount(input.pager.start.intValue(), true);
updateRowData(input.pager.start.intValue(), Collections.<User>emptyList());
}
}
DefaultEventBus.get().fireEventFromSource(new GetUsersSuccess(input, output), UserController.this);
}
@Override
public void onFailure(Throwable caught) {
getUsersRequest = null;
DefaultEventBus.get().fireEventFromSource(new GetUsersFailure(input, caught), UserController.this);
}
});
}
use of com.willshex.blogwt.shared.api.user.call.GetUsersResponse in project blogwt by billy1380.
the class UserService method getUsers.
public Request getUsers(GetUsersRequest input, AsyncSuccess<GetUsersRequest, GetUsersResponse> onSuccess, AsyncFailure<GetUsersRequest> onFailure) {
Request handle = null;
try {
handle = sendRequest(UserMethodGetUsers, input, new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
try {
GetUsersResponse outputParameter = new GetUsersResponse();
parseResponse(response, outputParameter);
if (onSuccess != null) {
onSuccess.call(input, outputParameter);
}
onCallSuccess(UserService.this, UserMethodGetUsers, input, outputParameter);
} catch (JSONException | HttpException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodGetUsers, input, exception);
}
}
@Override
public void onError(Request request, Throwable exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodGetUsers, input, exception);
}
});
onCallStart(UserService.this, UserMethodGetUsers, input, handle);
} catch (RequestException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodGetUsers, input, exception);
}
return handle;
}
use of com.willshex.blogwt.shared.api.user.call.GetUsersResponse in project blogwt by billy1380.
the class UserOracle 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 GetUsersRequest input = ApiHelper.setAccessCode(new GetUsersRequest());
input.session = SessionController.get().sessionForApiCall();
input.query = request.getQuery();
input.pager = PagerHelper.createDefaultPager();
input.pager.count = Integer.valueOf(request.getLimit());
if (getUsersRequest != null) {
getUsersRequest.cancel();
}
clearSelected();
getUsersRequest = ApiHelper.createUserClient().getUsers(input, new AsyncCallback<GetUsersResponse>() {
@Override
public void onSuccess(GetUsersResponse output) {
if (output.status == StatusType.StatusTypeSuccess && output.pager != null) {
foundItems(request, callback, output.users);
} else {
foundItems(request, callback, Collections.<User>emptyList());
}
}
@Override
public void onFailure(Throwable caught) {
GWT.log("Error getting users with query " + input.query, caught);
foundItems(request, callback, Collections.<User>emptyList());
}
});
}
Aggregations