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.
Strange Form behaviour with NestedMethodProperty
Hi
I have a form which has NestedMethodProperty for one of the form field's bean property when i set that field as not mandory i see a strange NullPointerexception on the client side in the browser but nothing at the server side. But if i set the field as required i don't see any error. Why is this strange behaviour caused. I have been strugling with this error for the past three days without any clue. See the attachment of the screen shot
Regards
Ajay
Problem solved.
To avoid Null pointer exception on Nested method property's getValue method we have to create empty objects. As @NestedMethodProperty mandates that all intermediate getters must return non-null values.
Ajay Kumar Bathula: To avoid Null pointer exception on Nested method property's getValue method we have to create empty objects. As @NestedMethodProperty mandates that all intermediate getters must return non-null values.
This is related to enhancement request #7229 to add an option to treat intermediate nulls as nulls for the nested property.
Hi Ajay,
Could you explain better with an example how you have done to solve that problem?
Thanks in advance.
David Modino: Hi Ajay,
Could you explain better with an example how you have done to solve that problem?
Thanks in advance.
You can take a look at a "hack" I used in ExpressUI:
https://github.com/juanosuna/expressui-framework/blob/master/expressui-core/src/main/java/com/vaadin/data/util/EnhancedNestedMethodProperty.java
If a null occurs anywhere in the nested property path, then null is returned. And if a value is set on a nested property path that contains nulls, empty values are automatically created using reflection and inserted into the tree.
You can see in my live demo that nested properties are used quite a lot in various results and forms.
Juan
Hi I'm using the vaadin 7.1.7 and this exception still happens, I didn't understand how to fix it!
The javadoc for NestedMethodProperty and some of the methods using it implicitly specifies that there should not be any intermediate nulls along the path, so it works as specified.
However, in the Vaadin 7.2 branch the behavior has been changed so that intermediate nulls simply produce null as the result, and we are considering introducing the change even in Vaadin 7.1.x (#12884) despite it resulting in a minor API change.
Hi, thanks for reply, but is there any way to avoid this error?
Maybe the problem here is not the same issue that occurs with me, I have created a new post here about this issue
https://vaadin.com/forum#!/thread/4553858