I have the following POJOS
Class Person{
private String name;
private Address address;
get…set
}
Class Address{
private String street;
get…set
}
My code
BeanItem personItem = new BeanItem(person);
I have use
personItem.expandProperty(“address”,“street”);
and
personItem.addNestedProperty(“address.street”);
The problem is that person.address is null! and the NullPointerException shows, if I change the constructor of the Person class to create an instance of the Address, it works, but this properties will be mandatory and it cant be mandatory.
The error log
Caused by: com.vaadin.data.util.MethodProperty$MethodException
at com.vaadin.data.util.NestedMethodProperty.getValue(NestedMethodProperty.java:205)
at com.vaadin.data.util.TransactionalPropertyWrapper.getValue(TransactionalPropertyWrapper.java:73)
at com.vaadin.ui.AbstractField.getDataSourceValue(AbstractField.java:299)
at com.vaadin.ui.AbstractField.setPropertyDataSource(AbstractField.java:629)
… 56 more
Caused by: java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.vaadin.data.util.NestedMethodProperty.getValue(NestedMethodProperty.java:201)
I just use nestedproperties, how can I do that?