Search in sources :

Example 1 with GetPostSuccess

use of com.willshex.blogwt.client.api.blog.event.GetPostEventHandler.GetPostSuccess in project blogwt by billy1380.

the class PostController method getPost.

public void getPost(Post post) {
    final GetPostRequest input = SessionController.get().setSession(ApiHelper.setAccessCode(new GetPostRequest())).post(post);
    if (getPostRequest != null) {
        getPostRequest.cancel();
    }
    getPostRequest = ApiHelper.createBlogClient().getPost(input, new AsyncCallback<GetPostResponse>() {

        @Override
        public void onSuccess(GetPostResponse output) {
            getPostRequest = null;
            boolean retryingGetWithSlug = false;
            if (output.status == StatusType.StatusTypeSuccess) {
                if (output.post != null) {
                }
            } else {
                if (input.post.id != null) {
                    getPost(new Post().slug(input.post.id.toString()));
                    retryingGetWithSlug = true;
                }
            }
            if (!retryingGetWithSlug) {
                DefaultEventBus.get().fireEventFromSource(new GetPostSuccess(input, output), PostController.this);
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            getPostRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetPostFailure(input, caught), PostController.this);
        }
    });
}
Also used : Post(com.willshex.blogwt.shared.api.datatype.Post) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetPostRequest(com.willshex.blogwt.shared.api.blog.call.GetPostRequest) GetPostSuccess(com.willshex.blogwt.client.api.blog.event.GetPostEventHandler.GetPostSuccess) GetPostFailure(com.willshex.blogwt.client.api.blog.event.GetPostEventHandler.GetPostFailure) GetPostResponse(com.willshex.blogwt.shared.api.blog.call.GetPostResponse)

Aggregations

AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 GetPostFailure (com.willshex.blogwt.client.api.blog.event.GetPostEventHandler.GetPostFailure)1 GetPostSuccess (com.willshex.blogwt.client.api.blog.event.GetPostEventHandler.GetPostSuccess)1 GetPostRequest (com.willshex.blogwt.shared.api.blog.call.GetPostRequest)1 GetPostResponse (com.willshex.blogwt.shared.api.blog.call.GetPostResponse)1 Post (com.willshex.blogwt.shared.api.datatype.Post)1