When a new contact is added it's id is never set. Because the id field
is a string it is stored as "". That is how the first contact is
added. Now every time you create a new contact you overwrite the
contact with key "". To fix this you need to set the value of the id.
I did this by changing the doSave method in EditContactsPresenter.
private void doSave() {
contact.setFirstName(display.getFirstName().getValue());
contact.setLastName(display.getLastName().getValue());
contact.setEmailAddress(display.getEmailAddress().getValue());
if(History.getToken.equals("add")
rpcService.updateContact(contact, new AsyncCallback<Contact>()
{
public void onSuccess(Contact result) {
eventBus.fireEvent(new
ContactUpdatedEvent(result));
}
public void onFailure(Throwable caught) {
Window.alert("Error updating contact");
}
});
else
rpcService.updateContact(contact, new AsyncCallback<Contact>()
{
public void onSuccess(Contact result) {
eventBus.fireEvent(new
ContactUpdatedEvent(result));
}
public void onFailure(Throwable caught) {
Window.alert("Error updating contact");
}
});
}
On Aug 3, 1:38 pm, WillSpecht <[email protected]> wrote:
> I recently tried to follow the Large scale application development and
> MVP tutorial. The tutorial was great but I am having a hard time with
> a few things.
>
> If you try and add a contact to the list, the contact is created. If
> you try and add another contact, you are taken to the edit screen of
> the last contact you created. No more contacts can be added once you
> add your first contact. What needs to be changed so you can add more
> than one contact.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.