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.
TreeTable and beans
Hi,
I am adding elements to a TreeTable, but all I get are the rows without any text.
I'll provide examples to clarify (simplified code):
First I add container properties, set the visible columns and the headers:
addContainerProperty("name", String.class, null);
addContainerProperty("surname", String.class, null);
setVisibleColumns("name", "surname");
setColumnHeaders("Name", "Surname");
The class Person:
private final class Person {
private final String name;
private final String surname;
// getters and setters
}
Then I add the elements in a loop like this:
Person elem = new Person("nameX", "surnameX");
addItem(elem);
This gives me a TreeTable with as many rows as elements I add, but everything is blank.
If instead I add the items as Object, then it works:
addItem(new Object{"nameX", "surnameX"}, "itemid");
The question is: is it not possible to use beans as items in TreeTables? If it is, what am I doing wrong?
I assume the line about adding objects should read
addItem(new Object[]{"nameX", "surnameX"}, "itemid");
i.e., you're adding the cells for a row as Array of Objects.
If you want to use beans, you need to use a container that supports them (BeanItemContainer for example).
Unfortunately BeanItemContainer doesn't support hierarchical components.
See this thread for some suggestions: https://vaadin.com/forum#!/thread/1928897