List of usage examples for com.google.gwt.gdata.client.gbase ItemsEntry getAttributes
public final native MapAttribute getAttributes() ;
From source file:com.google.gwt.gdata.sample.hellogdata.client.GoogleBaseRetrieveItemAttributesDemo.java
License:Apache License
/** * Retrieve the items feed using the Google Base service and * the items feed uri. In GData all get, insert, update * and delete methods always receive a callback defining success * and failure handlers.//from w ww . java 2 s.c o m * Here, the failure handler displays an error message while the * success handler obtains the first Item entry with a title * starting with "GWT-GoogleBase-Client" and calls showData * to display the item's attributes. * * @param itemsFeedUri The uri of the items feed */ private void getItems(String itemsFeedUri) { showStatus("Loading items feed...", false); service.getItemsFeed(itemsFeedUri, new ItemsFeedCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while retrieving the items feed: " + caught.getMessage(), true); } public void onSuccess(ItemsFeed result) { ItemsEntry[] entries = result.getEntries(); if (entries.length == 0) { showStatus("You have no items.", false); } else { ItemsEntry targetItem = null; for (ItemsEntry entry : entries) { String title = entry.getTitle().getText(); if (title.startsWith("GWT-GoogleBase-Client")) { targetItem = entry; break; } } if (targetItem == null) { showStatus("No item found that contains 'GWT-GoogleBase-Client' " + "in the title.", false); } else { showData(targetItem.getAttributes()); } } } }); }
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 ww w. j a va 2 s . c o 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); } }); }