Search in sources :

Example 1 with GetUsersFailure

use of com.willshex.blogwt.client.api.user.event.GetUsersEventHandler.GetUsersFailure 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);
        }
    });
}
Also used : GetUsersResponse(com.willshex.blogwt.shared.api.user.call.GetUsersResponse) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetUsersFailure(com.willshex.blogwt.client.api.user.event.GetUsersEventHandler.GetUsersFailure) GetUsersSuccess(com.willshex.blogwt.client.api.user.event.GetUsersEventHandler.GetUsersSuccess) GetUsersRequest(com.willshex.blogwt.shared.api.user.call.GetUsersRequest)

Aggregations

AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 GetUsersFailure (com.willshex.blogwt.client.api.user.event.GetUsersEventHandler.GetUsersFailure)1 GetUsersSuccess (com.willshex.blogwt.client.api.user.event.GetUsersEventHandler.GetUsersSuccess)1 GetUsersRequest (com.willshex.blogwt.shared.api.user.call.GetUsersRequest)1 GetUsersResponse (com.willshex.blogwt.shared.api.user.call.GetUsersResponse)1