Search in sources :

Example 1 with GetRolesFailure

use of com.willshex.blogwt.client.api.user.event.GetRolesEventHandler.GetRolesFailure 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);
        }
    });
}
Also used : GetRolesFailure(com.willshex.blogwt.client.api.user.event.GetRolesEventHandler.GetRolesFailure) GetRolesSuccess(com.willshex.blogwt.client.api.user.event.GetRolesEventHandler.GetRolesSuccess) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetRolesRequest(com.willshex.blogwt.shared.api.user.call.GetRolesRequest) GetRolesResponse(com.willshex.blogwt.shared.api.user.call.GetRolesResponse)

Aggregations

AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 GetRolesFailure (com.willshex.blogwt.client.api.user.event.GetRolesEventHandler.GetRolesFailure)1 GetRolesSuccess (com.willshex.blogwt.client.api.user.event.GetRolesEventHandler.GetRolesSuccess)1 GetRolesRequest (com.willshex.blogwt.shared.api.user.call.GetRolesRequest)1 GetRolesResponse (com.willshex.blogwt.shared.api.user.call.GetRolesResponse)1