Example usage for com.google.gwt.gdata.client.contacts ContactEntryCallback ContactEntryCallback

List of usage examples for com.google.gwt.gdata.client.contacts ContactEntryCallback ContactEntryCallback

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.contacts ContactEntryCallback ContactEntryCallback.

Prototype

ContactEntryCallback

Source Link

Usage

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

License:Apache License

/**
 * Create a contact by inserting a contact entry into
 * a contacts feed./*from www. ja  v  a2  s .c  om*/
 * Set the contact's title and contents to an arbitrary string. Here
 * we prefix the title with 'GWT-Contacts-Client' so that
 * we can identify which contacts were created by this demo.
 * On success and failure, display a status message.
 * 
 * @param contactFeedUri The uri of the contact feed into which to
 * insert the new contact entry
 */
private void createContact(String contactFeedUri) {
    showStatus("Creating contact...", false);
    ContactEntry entry = ContactEntry.newInstance();
    entry.setTitle(Text.newInstance());
    entry.getTitle().setText("GWT-Contacts-Client - Create Contact");
    entry.setContent(Text.newInstance());
    entry.getContent().setText("content info here");
    Email email = Email.newInstance();
    email.setAddress("GWT-Contacts-Client@domain.com");
    email.setPrimary(true);
    email.setRel(Email.REL_HOME);
    entry.setEmailAddresses(new Email[] { email });
    service.insertEntry(contactFeedUri, entry, new ContactEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while creating a contact: " + caught.getMessage(), true);
        }

        public void onSuccess(ContactEntry result) {
            showStatus("Created a contact.", false);
        }
    });
}

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

License:Apache License

/**
 * Delete a contact entry using the Contact service and
 * the contact entry uri.//  w  ww .  j  a va  2  s.  c  o m
 * On success and failure, display a status message.
 * 
 * @param contactEntryUri The uri of the contact entry to delete
 * @param etag The etag of the entry to be deleted
 */
private void deleteContact(String contactEntryUri, String etag) {
    showStatus("Deleting a contact...", false);
    GDataRequestParameters pars = GDataRequestParameters.newInstance();
    pars.setEtag(etag);
    service.deleteEntry(contactEntryUri, new ContactEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while deleting a contact: " + caught.getMessage(), true);
        }

        public void onSuccess(ContactEntry result) {
            showStatus("Deleted a contact.", false);
        }
    }, pars);
}