From: Matti Tahvonen Date: Sat, 4 Apr 2009 20:27:20 +0000 (+0000) Subject: fixes #2823 X-Git-Tag: 6.7.0.beta1~3027 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=60221b16a87d721a2d271f3d3ec4360a18d46c9b;p=vaadin-framework.git fixes #2823 svn changeset:7308/svn branch:6.0 --- diff --git a/src/com/itmill/toolkit/ui/Table.java b/src/com/itmill/toolkit/ui/Table.java index b91fa614fd..1ad0eda6ad 100644 --- a/src/com/itmill/toolkit/ui/Table.java +++ b/src/com/itmill/toolkit/ui/Table.java @@ -1370,14 +1370,6 @@ public class Table extends AbstractSelect implements Action.Container, // check in current pageBuffer already has row int index = firstIndex + i; if (p != null || isGenerated) { - if (p instanceof Property.ValueChangeNotifier) { - if (oldListenedProperties == null - || !oldListenedProperties.contains(p)) { - ((Property.ValueChangeNotifier) p) - .addListener(this); - } - listenedProperties.add(p); - } if (index < firstIndexNotInCache && index >= pageBufferFirstIndex) { // we have data already in our cache, @@ -1397,6 +1389,32 @@ public class Table extends AbstractSelect implements Action.Container, value = p.getValue(); } else if (p != null) { value = getPropertyValue(id, colids[j], p); + /* + * If returned value is Component (via + * fieldfactory or overridden + * getPropertyValue) we excpect it to listen + * property value changes. Otherwise if + * property emits value change events, table + * will start to listen them and refresh + * content when needed. + */ + if (!(value instanceof Component) + && p instanceof Property.ValueChangeNotifier) { + // only add listener to property once + if (oldListenedProperties == null + || !oldListenedProperties + .contains(p)) { + ((Property.ValueChangeNotifier) p) + .addListener(this); + } + /* + * register listened properties, so we + * can do proper cleanup to free memory. + * Essential if table has loads of data + * and it is used for a long time. + */ + listenedProperties.add(p); + } } else { value = getPropertyValue(id, colids[j], null);