Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Bind table to a Bean with list property
Hello,
So I have this Bean:
public class Person{
private String name;
private List<String> achievements;
}
...getters/setters...
And I want to bind it to a table, but only the List, in such a way that each row represent one element of that list.
Right now I have this:
//a generated bean
Table table = new Table();
BeanItemContainer<Person> container = new BeanItemContainer<>(Person.class);
container.addBean(person);
table.setContainerDataSource(container);
table.setVisibleColumns("achievements");
And I get this (rightfuly):
http://imgur.com/a/9lwdt
What I need is one entry from the list on each row.
Also, there'll always be only one item in the container (so maybe the wrong container ?).
Sorry if it seems stupid, but this will help me understand data binding in general.
Any ideas ?
Hello,
The way you have setup the table and bean item container, it dipslays a separate row for each person. And the properties of each person, like name and achievemnts are rendered as columns. The output you get is correct.
If you want to display each achievemnt in a separate row, then maybe consider adding those items to the table.
You could for example do something like this:
Table table = new Table();
table.addContainerProperty("Achievement", String.class, "");
List<String> achievements = person.getAchievements();
for (String achievemnt : achievements) {
table.addItem(new Object {achievemnt}, null);
}
Hope this helps,
Goran