Example usage for com.google.gwt.gdata.client.gbase ItemsEntry updateEntry

List of usage examples for com.google.gwt.gdata.client.gbase ItemsEntry updateEntry

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.gbase ItemsEntry updateEntry.

Prototype

public final native void updateEntry(Callback<E> callback) ;

Source Link

Document

Updates the entry in the feed by sending the representation of this entry.

Usage

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

License:Apache License

/**
 * Update an item by making use of the updateEntry
 * method of the Entry class./*from www .j  a  va2  s.  co m*/
 * Set the item's title to an arbitrary string. Here
 * we prefix the title with 'GWT-GoogleBase-Client' so that
 * we can identify which items were updated by this demo.
 * We also update the target_country property for this item.
 * On success and failure, display a status message.
 * 
 * @param itemsEntry The item entry which to update
 */
private void updateItem(ItemsEntry itemsEntry) {
    showStatus("Updating item...", false);
    itemsEntry.setTitle(Text.newInstance());
    itemsEntry.getTitle().setText("GWT-GoogleBase-Client - updated item");
    MapAttribute attributes = itemsEntry.getAttributes();
    if (attributes.contains("target_country")) {
        attributes.get("target_country")[0].setValue("UK");
    }
    itemsEntry.updateEntry(new ItemsEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while updating an item: " + caught.getMessage(), true);
        }

        public void onSuccess(ItemsEntry result) {
            showStatus("Updated an item.", false);
        }
    });
}