Problem with Inheritance and Nested Container Property

Hello everyone!

I am encountering with a problem during adding nested Container property to a bean container.

I want to display some nested classes in a grid using the beanItemContainer.

I created a small example for understanding:

public class KlasseA {

    private String name;
    private KlasseB klasseB;
    private KlasseC klasseC;

    // getter, setter, ...
public class KlasseB {

    private String land;

    // getter, setter, ...
public class KlasseC {

    private boolean bool;

    // getter, setter, ...

public class KlasseD extends KlasseB {

private Calendar datum;

// getter, setter, ...

[/code]Then I create a ArrayList

ArrayList<KlasseA> liste = new ArrayList<>();

KlasseD d1 = new KlasseD("Deutschland", new GregorianCalendar());
KlasseD d2 = new KlasseD("Finnland", new GregorianCalendar(2017, 10, 6));

KlasseC c1 = new KlasseC(true);
KlasseC c2 = new KlasseC(false);

KlasseA a1 = new KlasseA("Objekt KlasseA 1", (KlasseB) d1, c1);
KlasseA a2 = new KlasseA("Objekt KlasseA 2", (KlasseB) d2, c2);


Then I create the grid, add the Data to the container and so on …

Now I want to add the nested container properties with


up to here, everything is fine!

As you see above the klasseB-attribute of every KlasseA-object is originally a KlasseD-object and I only casted it.

So my question is, if there is any way to get the attribute “datum” in the KlasseD.

I tried this:

container.addNestedContainerProperty("klasseB.datum"); but I get a java.lang.IllegalArgumentException: Bean property ‘datum’ not found

and the table is displayed as in Attachment “result_after_exception.png”.

As result I want a table like in Attachment “result.png”.

Sadly, I’m not allowed to change the classes in any way!

Does anybody here can help me?

I’m using Vaadin version 7.7.7

As I see it, you need object of class KlasseD(not KlasseB) in class KlasseA. I really don’t know big design picture with class hierarchy here, but I can think of one dirty fix you can achieve what I think you want here. In KlasseB add getter for Datum that returns null, and override it in KlasseD.

Hi Julia, did you resolve this situation?