diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/MainUi.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/MainUi.java index 79618ad..9387409 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/MainUi.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/MainUi.java @@ -12,6 +12,7 @@ import com.vaadin.ui.VerticalLayout; import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonGrid; @SpringUI public class MainUi extends UI { @@ -24,11 +25,13 @@ public class MainUi extends UI { protected void init(VaadinRequest request) { VerticalLayout layout = new VerticalLayout(); layout.addComponent(new Label("Persons found:")); + List persons = dao.list(); - for (Person p : persons) { - layout.addComponent( - new Label(p.getPrename() + " " + p.getSurname())); - } + PersonGrid grid = new PersonGrid(); + grid.setItems(persons); + grid.setCaption("Person Grid"); + + layout.addComponent(grid); setContent(layout); } diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonGrid.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonGrid.java index d4e519b..2206393 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonGrid.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonGrid.java @@ -13,9 +13,10 @@ public class PersonGrid extends Grid { .getDateInstance(DateFormat.MEDIUM); public PersonGrid() { - addColumn(Person::getPrename); - addColumn(Person::getSurname); - addColumn(Person::getBirth, b -> birthFormat.format(b)); + addColumn(Person::getPrename).setCaption("Vorname"); + addColumn(Person::getSurname).setCaption("Nachname"); + addColumn(Person::getBirth, b -> b != null ? birthFormat.format(b) : "") + .setCaption("Geburtstag"); } }