Search in sources :

Example 1 with GetPropertiesSuccess

use of com.willshex.blogwt.client.api.blog.event.GetPropertiesEventHandler.GetPropertiesSuccess 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);
        }
    });
}
Also used : JsonArray(com.google.gson.JsonArray) GetPropertiesRequest(com.willshex.blogwt.shared.api.blog.call.GetPropertiesRequest) GetPropertiesFailure(com.willshex.blogwt.client.api.blog.event.GetPropertiesEventHandler.GetPropertiesFailure) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetPropertiesSuccess(com.willshex.blogwt.client.api.blog.event.GetPropertiesEventHandler.GetPropertiesSuccess) GetPropertiesResponse(com.willshex.blogwt.shared.api.blog.call.GetPropertiesResponse) Property(com.willshex.blogwt.shared.api.datatype.Property)

Aggregations

JsonArray (com.google.gson.JsonArray)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 GetPropertiesFailure (com.willshex.blogwt.client.api.blog.event.GetPropertiesEventHandler.GetPropertiesFailure)1 GetPropertiesSuccess (com.willshex.blogwt.client.api.blog.event.GetPropertiesEventHandler.GetPropertiesSuccess)1 GetPropertiesRequest (com.willshex.blogwt.shared.api.blog.call.GetPropertiesRequest)1 GetPropertiesResponse (com.willshex.blogwt.shared.api.blog.call.GetPropertiesResponse)1 Property (com.willshex.blogwt.shared.api.datatype.Property)1