List of usage examples for com.google.gwt.gdata.client.blogger PostEntry setContent
public final native void setContent(Text content) ;
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./*w ww . java 2s. c om*/ * 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); } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.BloggerUpdateBlogPostDemo.java
License:Apache License
/** * Update a blog post by making use of the updateEntry * method of the Entry class.//from w w w. j av a 2 s. c om * 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 updated by this demo. * We also update the name of one of the post's categories. * On success and failure, display a status message. * * @param postEntry The post entry which to update */ private void updatePost(PostEntry postEntry) { showStatus("Updating post entry...", false); postEntry.getTitle().setText("GWT-Blogger-Client - updated post"); postEntry.setContent(Text.newInstance()); postEntry.getContent().setText("My updated post"); Category[] categories = postEntry.getCategories(); for (Category category : categories) { if (category.getTerm().equals("Label1")) { category.setTerm("Label1-updated"); } } postEntry.updateEntry(new PostEntryCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while updating a blog post: " + caught.getMessage(), true); } public void onSuccess(PostEntry result) { showStatus("Updated a blog entry.", false); } }); }