summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/data/util/TransactionalPropertyWrapper.java
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/com/vaadin/data/util/TransactionalPropertyWrapper.java')
-rw-r--r--server/src/com/vaadin/data/util/TransactionalPropertyWrapper.java28
1 files changed, 21 insertions, 7 deletions
diff --git a/server/src/com/vaadin/data/util/TransactionalPropertyWrapper.java b/server/src/com/vaadin/data/util/TransactionalPropertyWrapper.java
index 6b0119c503..c3cef6a0ec 100644
--- a/server/src/com/vaadin/data/util/TransactionalPropertyWrapper.java
+++ b/server/src/com/vaadin/data/util/TransactionalPropertyWrapper.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 Vaadin Ltd.
+ * Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
@@ -48,18 +48,32 @@ public class TransactionalPropertyWrapper<T> extends AbstractProperty<T>
private boolean inTransaction = false;
private boolean valueChangePending;
private T valueBeforeTransaction;
+ private final ValueChangeListener listener = new ValueChangeListener() {
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ fireValueChange();
+ }
+ };
public TransactionalPropertyWrapper(Property<T> wrappedProperty) {
this.wrappedProperty = wrappedProperty;
if (wrappedProperty instanceof ValueChangeNotifier) {
((ValueChangeNotifier) wrappedProperty)
- .addListener(new ValueChangeListener() {
+ .addValueChangeListener(listener);
+ }
+ }
- @Override
- public void valueChange(ValueChangeEvent event) {
- fireValueChange();
- }
- });
+ /**
+ * Removes the ValueChangeListener from wrapped Property that was added by
+ * TransactionalPropertyWrapper.
+ *
+ * @since 7.1.15
+ */
+ public void detachFromProperty() {
+ if (wrappedProperty instanceof ValueChangeNotifier) {
+ ((ValueChangeNotifier) wrappedProperty)
+ .removeValueChangeListener(listener);
}
}