aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2014-12-09 21:18:50 +0200
committerArtur Signell <artur@vaadin.com>2014-12-09 21:19:40 +0200
commit52fb8cd941caad7d9c6277d7b154498abb6b99e6 (patch)
tree9036959d709d76001d7ef575816c5007fae7d224 /server
parentb579c8aa1f116613bc2c54a562619dbba0608a5d (diff)
downloadvaadin-framework-52fb8cd941caad7d9c6277d7b154498abb6b99e6.tar.gz
vaadin-framework-52fb8cd941caad7d9c6277d7b154498abb6b99e6.zip
Make addNestedContainerBean work with existing bean item container items (#15355)
Change-Id: I04a91349fce452aa26c304413061440ad74465cc
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/data/util/AbstractBeanContainer.java2
-rw-r--r--server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java42
2 files changed, 43 insertions, 1 deletions
diff --git a/server/src/com/vaadin/data/util/AbstractBeanContainer.java b/server/src/com/vaadin/data/util/AbstractBeanContainer.java
index 7d7d71c423..fad0934e53 100644
--- a/server/src/com/vaadin/data/util/AbstractBeanContainer.java
+++ b/server/src/com/vaadin/data/util/AbstractBeanContainer.java
@@ -880,7 +880,7 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE> extends
model.put(qualifiedPropertyId, pd);
model.remove(propertyId);
for (BeanItem<BEANTYPE> item : itemIdToItem.values()) {
- item.addItemProperty(propertyId,
+ item.addItemProperty(qualifiedPropertyId,
pd.createProperty(item.getBean()));
item.removeItemProperty(propertyId);
}
diff --git a/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java b/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java
index 01c282e294..514bf70416 100644
--- a/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java
+++ b/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java
@@ -12,6 +12,7 @@ import org.junit.Assert;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
+import com.vaadin.data.util.NestedMethodPropertyTest.Address;
/**
* Test basic functionality of BeanItemContainer.
@@ -740,4 +741,45 @@ public class BeanItemContainerTest extends AbstractBeanContainerTest {
assertNull(container.getContainerProperty(john, "address.street")
.getValue());
}
+
+ public void testAddNestedContainerBeanBeforeData() {
+ BeanItemContainer<NestedMethodPropertyTest.Person> container = new BeanItemContainer<NestedMethodPropertyTest.Person>(
+ NestedMethodPropertyTest.Person.class);
+
+ container.addNestedContainerBean("address");
+
+ assertTrue(container.getContainerPropertyIds().contains(
+ "address.street"));
+
+ NestedMethodPropertyTest.Person john = new NestedMethodPropertyTest.Person(
+ "John", new Address("streetname", 12345));
+ container.addBean(john);
+
+ assertTrue(container.getItem(john).getItemPropertyIds()
+ .contains("address.street"));
+ assertEquals("streetname",
+ container.getItem(john).getItemProperty("address.street")
+ .getValue());
+
+ }
+
+ public void testAddNestedContainerBeanAfterData() {
+ BeanItemContainer<NestedMethodPropertyTest.Person> container = new BeanItemContainer<NestedMethodPropertyTest.Person>(
+ NestedMethodPropertyTest.Person.class);
+
+ NestedMethodPropertyTest.Person john = new NestedMethodPropertyTest.Person(
+ "John", new Address("streetname", 12345));
+ container.addBean(john);
+
+ container.addNestedContainerBean("address");
+
+ assertTrue(container.getContainerPropertyIds().contains(
+ "address.street"));
+ assertTrue(container.getItem(john).getItemPropertyIds()
+ .contains("address.street"));
+ assertEquals("streetname",
+ container.getItem(john).getItemProperty("address.street")
+ .getValue());
+
+ }
}