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());

Thank you, I’m still surprised by Java 8 features :slight_smile:

Enjoy! :wink:

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

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()
.