lausd-teacher / gwt-gdata

Automatically exported from code.google.com/p/gwt-gdata
0 stars 0 forks source link

Contact empty title when created ContactEntry #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run HelloGData's ContactsCreateContactDemo.java

What is the expected output? What do you see instead?
New Contact with "GWT-Contacts-Client - Create Contact" name.
Instead no name associated with this created contact.

What version of the product are you using? On what operating system?
GWT GData 2.2.1

Please provide any additional information below.

...
    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");
...

The title propety is simply not reflected for some reason for created 
contacts. However getTitle call on existing contacts (created with 
something else than GWT-GData) returns contact's name.

Original issue reported on code.google.com by peter.on...@gmail.com on 20 Mar 2010 at 10:15

GoogleCodeExporter commented 9 years ago
Looks like this has something to do with the change introduced in version 3.0 
of GData Contacts API: 
http://code.google.com/apis/contacts/docs/3.0/migration_guide.html#Java
***
Replace the uses of ContactEntry.setTitle (and getTitle) with appropriate uses 
of ContactEntry.setName(Name 
name). Note that the Name is not a simple string, but a whole structure 
consisting of several name components, 
so in reality the necessary adaptations will be more complex.

Original comment by peter.on...@gmail.com on 5 Apr 2010 at 9:59

GoogleCodeExporter commented 9 years ago
The getName/setName methods are missing from the PersonEntry class, which
ContactEntry inherits from. The gwt-gdata is auto-generated from the JS docs
(http://code.google.com/apis/gdata/jsdoc/2.2/index.html). Since the PersonEntry 
class
is missing from the JS docs in 2.2, gwt-gdata 2.2.1 is missing some methods for
PersonEntry.

You can easily add the missing getName/setName methods using JSNI:

private native void setName(ContactEntry entry, com.google.gwt.gdata.client.Name
name) /*-{
  entry.setName(name);
}-*/;

private native com.google.gwt.gdata.client.Name getName(ContactEntry entry) /*-{
  return entry.getName();
}-*/;

You can the set the entry's name using the following:
ContactEntry entry = ContactEntry.newInstance();
GivenName john = GivenName.newInstance();
john.setValue("John");
FamilyName smith = FamilyName.newInstance();
smith.setValue("Smith");
Name name = Name.newInstance();
name.setGivenName(john);
name.setFamilyName(smith);
setName(entry, name);

The next version of gwt-gdata will correct this issue. Thanks for reporting it.

Original comment by non.gwt....@gmail.com on 29 Apr 2010 at 5:22

GoogleCodeExporter commented 9 years ago

Original comment by bobbysoa...@gmail.com on 29 Apr 2010 at 5:23

GoogleCodeExporter commented 9 years ago
doing the workaround you suggest results in the following error

An error occurred while creating a contact: [Line 1, Column 887, element 
gd:familyName] Unknown attribute: '__gwt_ObjectId'

Original comment by u...@worldticket.net on 27 Dec 2011 at 12:07