Example usage for com.google.gwt.gdata.client.blogger PostEntry setTitle

List of usage examples for com.google.gwt.gdata.client.blogger PostEntry setTitle

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.blogger PostEntry setTitle.

Prototype

public final native void setTitle(Text title) ;

Source Link

Document

Sets the title.

Usage

From source file:com.google.gwt.gdata.sample.hellogdata.client.BloggerCreateBlogPostDemo.java

License:Apache License

/**
 * Create a blog post by inserting a post entry into
 * a blog posts feed.//from  w w w .ja  va  2 s .c  o m
 * Set the post's title and contents to an arbitrary string. Here
 * we prefix the title with 'GWT-Blogger-Client' so that
 * we can identify which posts were created by this demo.
 * To avoid publishing the new post we set the Atom control status
 * to "draft".
 * Finally, we associate the new post with two categories.
 * On success and failure, display a status message.
 * 
 * @param postFeed The post feed into which to insert the new post
 */
private void insertPost(BlogPostFeed postFeed) {
    showStatus("Creating blog post entry...", false);
    PostEntry newPost = PostEntry.newInstance();
    newPost.setTitle(Text.newInstance());
    newPost.getTitle().setText("GWT-Blogger-Client - inserted post");
    newPost.setContent(Text.newInstance());
    newPost.getContent().setText("This is the body of the blog post. We " + "can include <b>HTML</b> tags.");
    newPost.setControl(Control.newInstance());
    newPost.getControl().setDraft(Draft.newInstance());
    newPost.getControl().getDraft().setValue(Draft.VALUE_YES);
    Category cat1 = Category.newInstance();
    cat1.setScheme("http://www.blogger.com/atom/ns#");
    cat1.setTerm("Label1");
    Category cat2 = Category.newInstance();
    cat2.setLabel("http://www.blogger.com/atom/ns#");
    cat2.setTerm("Label2");
    newPost.setCategories(new Category[] { cat1, cat2 });
    postFeed.insertEntry(newPost, new PostEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while creating a blog post: " + caught.getMessage(), true);
        }

        public void onSuccess(PostEntry result) {
            showStatus("Created a blog entry titled '" + result.getTitle().getText() + "'.", false);
        }
    });
}