Browse Source

Support null intermediate properties in NestedMethodProperty (#10134)

Ignore null intermediate properties in setValue().

Forward port of #10085 in 7.7 to the compatibility package.
tags/8.2.0.alpha3
Olli Tietäväinen 6 years ago
parent
commit
0eabcf3094

+ 3
- 0
compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java View File

@@ -253,6 +253,9 @@ public class NestedMethodProperty<T> extends AbstractProperty<T> {
Object object = instance;
for (int i = 0; i < getMethods.size() - 1; i++) {
object = getMethods.get(i).invoke(object);
if (object == null) {
return;
}
}
setMethod.invoke(object, new Object[] { value });
} catch (final InvocationTargetException e) {

+ 6
- 0
compatibility-server/src/test/java/com/vaadin/v7/data/util/NestedMethodPropertyTest.java View File

@@ -308,6 +308,12 @@ public class NestedMethodPropertyTest {
Address address2 = new Address("Other street", 12345);
addressProperty.setValue(address2);
assertEquals("Other street", streetProperty.getValue());

Address address3 = null;
addressProperty.setValue(address3);
assertEquals(null, addressProperty.getValue());
streetProperty.setValue("Ruukinkatu");
assertEquals(null, streetProperty.getValue());
}

@Test

Loading…
Cancel
Save