Gaurav Sharma Gaurav Sharma - 12 days ago 5
Java Question

Vaadin: table container has object members

I'm extending the

BeanItemContainer
and using it as a container for a table in Vaadin.

public class MyContainer extends BeanItemContainer<MyClass>
implements Serializable {
...
}


The
MyClass
object has a structure as shown below:

public class MyClass {
private int id;
private InnerClass data;
...
}


And the InnerClass has the structure:

public class InnerClass {
private int propA;
private String propB;
...
}


I'd like to display the id and data.propA columns but I'm not sure how to in Vaadin.

Answer

The solution is to use the addNestedContainerProperty property.

Refer to https://vaadin.com/book/-/page/datamodel.container.html for details.