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:

[code]
//a generated bean

Table table = new Table();
BeanItemContainer container = new BeanItemContainer<>(Person.class);
container.addBean(person);

table.setContainerDataSource(container);

table.setVisibleColumns(“achievements”);
[/code]And I get this (rightfuly):
[url=http://imgur.com/a/9lwdt]
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.

[/url]
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