When adding a new contact, the identifier is never set. Since the id field is a string, it is saved as ". This adds the first contact. Now, every time you create a new contact, you overwrite the contact with the" "key. To fix this, you need to set the id value. I did this by changing the method doSave 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"); } }); }
source share