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.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Grid v8 nested properties
Hi,
while experimenting with the new Grid (v8) API, I wondered how to set a nested property on a (databound) Column (via DataProvider).
In v7 Grid it was possible via e.g. AbstractBeanContainer#addNestedContainerProperty
Anybody got ideas?
Yes, use a ValueProvider so you can show whatever you want. For example:
grid.addColumn(user -> user.getAddress().getCountry().getName());
Alejandro Duarte: Yes, use a ValueProvider so you can show whatever you want. For example:
grid.addColumn(user -> user.getAddress().getCountry().getName());
Thanks a lot Alejandro, I can sleep in peace...
Barbaros Baykut: Thanks a lot Alejandro, I can sleep in peace...
Haha cool! And at least you can. I can't today. Not much. Have to write a book. About Vaadin :) Deadlines! Anyway, sleep well!
But what to do if you want to do something with a column that refers to a nested property?
The only way I found is to store the column in a variable. But that is not very elegant, is it?
Alejandro Duarte: Yes, use a ValueProvider so you can show whatever you want. For example:
grid.addColumn(user -> user.getAddress().getCountry().getName());
Hi Alejandro.
When the address of any user in the ListDataProvider is null, I get a NullPointerException. How do you treat this exception?
I avoid throwing the exception using an if statement or ? operator: user -> user.getAddress() == null ? "" : user.getAddress().getCountry().getName().