Skip to content

Commit

Permalink
Extra 8 | Add delete event
Browse files Browse the repository at this point in the history
  • Loading branch information
amahdy committed Jun 2, 2017
1 parent f3d8304 commit 073cf84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/java/org/vaadin/stepbystep/MyUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public class MyUI extends UI {
Person original = service.getById(person.getId());
grid.getDataProvider().refreshItem(original);
return original;
}, person -> {
service.delete(person);
listPersons();
selectDefault();
});

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/vaadin/stepbystep/PersonEditorView.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ public class PersonEditorView extends PersonEditorDesign {
Binder<Person> binder = new Binder<>(Person.class);

public PersonEditorView(Consumer<Person> saveEvt,
Function<Person, Person> cancelEvt) {
Function<Person, Person> cancelEvt,
Consumer<Person> delEvt) {
binder.bindInstanceFields(this);

save.addClickListener(evt -> saveEvt.accept(binder.getBean()));
cancel.addClickListener(evt -> setPerson(cancelEvt.apply(binder.getBean())));
delete.addClickListener(evt -> delEvt.accept(binder.getBean()));
}

public void setPerson(Person value) {
Expand Down

0 comments on commit 073cf84

Please sign in to comment.