how to link an array to a table

When I have a array of a certain class. How can I add that array to a table?

Example:

class example() {
String name=“”;
Integer age=0;

// getters and setters
}

when I have an array of examples with 10 objects of the class example.
How can I easily map this class to a table. Or do I need to extract every record and set the property in the row of an table?

Chris

For this scenario there is the class com.vaadin.data.util.BeanItemContainer available. This is a Vaadin Container that manages a collection of com.vaadin.data.util.BeanItem objects. BeanItems automatically map the properties of a JavaBean on Vaadin Properties. So in your example, all you have to do is create a BeanItemContainer for your example class and populate that with the data in your array:

example[] arrayOfExamples = ...;
BeanItemContainer<example> container = new BeanItemContainer<example>();
container.addAll(java.util.Arrays.asList(arrayOfExamples));
table.setContainerDataSource(container);

thanks, that did the trick

C