Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Add nested objects properties in Vaadin 8 container

Kareem Jabr
5 years ago Apr 02, 2017 2:17pm

Since there is no BeanItemContainer now with the grid how is it possible to bind nested objects properties to the Grid, like:

class Person {
Address address;
}
class Address {
String street
}

I would like to bind Person::getAddress::getStreet

 

Nicklas Karlsson
5 years ago Apr 02, 2017 2:55pm
Kareem Jabr
5 years ago Apr 02, 2017 3:01pm
Kareem Jabr
5 years ago Apr 02, 2017 3:07pm
Kareem Jabr
5 years ago Apr 02, 2017 3:17pm

I solved it by setting unique column ids to the nested columns and using the following:

grid.addColumn(person -> person.getAddress().getStreet()).setCaption("Address Street").setId("streetAddress");
grid.setColumns("name","age", "streetAddress");
Nicklas Karlsson
5 years ago Apr 02, 2017 3:34pm

Kareem Jabr: why cannot we just say:

grid.AddColumn(Person::getAddress::getStreet);

Probably because Java doesn't support it(?) ;-)

But yes, it would be nice to have some native way of doing it instead of various workarounds like you outlined (or adding "flattening" getters in the root object etc)
 

Katerina Chantzara
4 years ago Sep 01, 2017 2:59pm
adil dalli
4 years ago Sep 07, 2017 2:41pm
Rodrigo Mateus
4 years ago Dec 15, 2017 8:33pm
adil dalli
4 years ago Dec 15, 2017 8:41pm
Rodrigo Mateus
4 years ago Dec 16, 2017 10:41am