NotesComponent sets Notetext only if not setPerson is running.

master
Markus Kreth 6 years ago
parent d8b28040a9
commit 66b7547453
  1. 2
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Person.java
  2. 6
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/NotesComponent.java

@ -30,7 +30,7 @@ import javax.persistence.Table;
@Entity
@Table(name = "person")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@NamedQuery(name = Person.QUERY_FINDALL, query = "SELECT p FROM Person p WHERE p.deleted is null")
@NamedQuery(name = Person.QUERY_FINDALL, query = "SELECT p FROM Person p WHERE p.deleted is null")
@NamedQuery(name = Person.QUERY_FINDLOGIN, query = "FROM Person WHERE username = :username AND password = :password AND deleted is"
+ " null")
public class Person extends BaseEntity implements Serializable {

@ -18,6 +18,8 @@ public class NotesComponent extends VerticalLayout {
private boolean hasChanges;
private boolean isUpdating = false;
public NotesComponent() {
notesComponent = new TextArea();
notesComponent.setMaxLength(2000);
@ -32,7 +34,7 @@ public class NotesComponent extends VerticalLayout {
}
private void textChange(ValueChangeEvent<String> ev) {
if (note != null) {
if (note != null && !isUpdating) {
if (ev.isUserOriginated()) {
hasChanges = true;
}
@ -41,6 +43,7 @@ public class NotesComponent extends VerticalLayout {
}
public void setPerson(Person person) {
isUpdating = true;
notesComponent.clear();
hasChanges = false;
if (person != null) {
@ -55,6 +58,7 @@ public class NotesComponent extends VerticalLayout {
note.setPerson(person);
}
}
isUpdating = false;
}
public boolean hasChanges() {

Loading…
Cancel
Save