Hi I am a newbie to Vaadin.
I am using Table property of vaadin to load the data from Domain Class but i have no idea how to set the table.additem
for the data.
I am using the following code to generate the column value
Table table = new Table("Customer Table");
table.addContainerProperty("Street", String.class, null);
for(DomainClass domainClass : domainClassList) {
// table.addItem(domainClass.getStreet());
}
layout.addComponent(table);
But it is showing the empty page.
A Vaadin best-practice is to work with Containers.
final Table table = new Table("Customer Table");
final BeanItemContainer<DomainClass> container = new BeanItemContainer<>(
DomainClass.class, domainList);
table.setContainerDataSource(container);
If the DomainClass has a getter getStreet()
then it's automatically mapped to a column with that name. Still you can set the table headers manually with table.setColumnHeader("street", "Street");
Maybe you find Vaadin's docs about Containers useful too.