This commit is contained in:
Filippo Ferrari 2024-07-27 18:13:51 +02:00
parent 0fc5b07f5e
commit 4d36b7dca2
2 changed files with 5 additions and 10 deletions

View file

@ -108,9 +108,8 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
// when a row is selected or deselected, populate form // when a row is selected or deselected, populate form
grid.asSingleSelect().addValueChangeListener(event -> { grid.asSingleSelect().addValueChangeListener(event -> {
if (event.getValue() != null) { if (event.getValue() != null) UI.getCurrent().navigate(String.format(EXPENSE_EDIT_ROUTE_TEMPLATE, event.getValue().getId()));
UI.getCurrent().navigate(String.format(EXPENSE_EDIT_ROUTE_TEMPLATE, event.getValue().getId())); else {
} else {
clearForm(); clearForm();
UI.getCurrent().navigate(ExpensesView.class); UI.getCurrent().navigate(ExpensesView.class);
} }
@ -164,9 +163,7 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
save.addClickListener(e -> { save.addClickListener(e -> {
try { try {
if (this.expense == null) { if (this.expense == null) this.expense = new Expense();
this.expense = new Expense();
}
binder.writeBean(this.expense); binder.writeBean(this.expense);
expenseService.update(this.expense); expenseService.update(this.expense);
clearForm(); clearForm();
@ -306,4 +303,4 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
} }
return badge; return badge;
} }
} }

View file

@ -105,9 +105,7 @@ public class PeopleView extends Div implements BeforeEnterObserver {
save.addClickListener(e -> { save.addClickListener(e -> {
try { try {
if (this.person == null) { if (this.person == null) this.person = new Person();
this.person = new Person();
}
binder.writeBean(this.person); binder.writeBean(this.person);
personService.update(this.person); personService.update(this.person);
clearForm(); clearForm();