Hari
Hari

Reputation: 511

How to display list of java.util.Properties object to Vaadin table ? Which container could help directly without looping?

I have collection of java.util.Properties objects, where each object contains key and values.

For example, my list has two properties object as below,

[{name=A, type=B, value=C},{name=D, type=E, value=F}]

They should be displayed in the Table as

name type value

A     B    C
D     E    F

I can loop thru each property object and add it to the table as described in the below url

Vaadin get the table contents into a Map

or convert the each property object to a bean and add it to table using BeanItemContainer.

Is there anyway to directly set the list of properties to container and add the container to the table ?

I am using Vaadin 8.6.4 where I can also use Vaadin 7 stuff.

Upvotes: 3

Views: 191

Answers (1)

Erik Lumme
Erik Lumme

Reputation: 5342

I'd suggest using a Vaadin 8 Grid. If I understood correctly, something like this could work (untested code)

Grid<Properties> grid = new Grid<>();
grid.addColumn(props -> props.get("name")).setHeader("Name");
grid.addColumn(props -> props.get("type")).setHeader("Type");
grid.addColumn(props -> props.get("value")).setHeader("Value");

grid.setItems(myListOfProperties);

Upvotes: 2

Related Questions