Bind table to a Bean with list property


So I have this Bean:

    public class Person{
        private String name;
        private List<String> achievements;

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 container = new BeanItemContainer<>(Person.class);


[/code]And I get this (rightfuly):


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 ?


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,