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?
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: