if (!isValid()) {
return;
}
AbstractOrderCommand command;
ContactFormBean contact = obtainContactFormBeanFromDatasource();
if (newContactMode) {
newContactMode = false;
CreateContactCommand createCommand = new CreateContactCommand();
createCommand.setNewContactName(contact.getName());
command = createCommand;
message = "Created new contact with name " + contact.getName();
} else {
ChangeContactNameCommand changeCommand = new ChangeContactNameCommand();
changeCommand.setContactNewName(contact.getName());
changeCommand.setContactId(contact.getIdentifier());
command = changeCommand;
message = "Changed name of contact into " + contact.getName();
}
commandBus.dispatch(new GenericCommandMessage<Object>(command));
fireEvent(new FormIsSuccessfullyCommittedEvent(this));
setReadOnly(true);
getApplication().getMainWindow().showNotification(message, Window.Notification.TYPE_TRAY_NOTIFICATION);