aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@itmill.com>2010-03-23 12:56:50 +0000
committerHenri Sara <henri.sara@itmill.com>2010-03-23 12:56:50 +0000
commit9e63d88cd1873c01d2e9cf1e0e6fc46bf78fe9bc (patch)
tree0f35e578ca88fd5ec865696de1cae0633fae0a10 /src
parent4938977aafdd83ba979e2f189a2ee7328acf750d (diff)
downloadvaadin-framework-9e63d88cd1873c01d2e9cf1e0e6fc46bf78fe9bc.tar.gz
vaadin-framework-9e63d88cd1873c01d2e9cf1e0e6fc46bf78fe9bc.zip
#4394 multiple value change events when setting field value
svn changeset:12041/svn branch:6.3
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/ui/AbstractField.java21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/com/vaadin/ui/AbstractField.java b/src/com/vaadin/ui/AbstractField.java
index 7ea4f2471e..35f186dd09 100644
--- a/src/com/vaadin/ui/AbstractField.java
+++ b/src/com/vaadin/ui/AbstractField.java
@@ -92,6 +92,13 @@ public abstract class AbstractField extends AbstractComponent implements Field,
private boolean modified = false;
/**
+ * Should value change event propagation from property data source to
+ * listeners of the field be suppressed. This is used internally while the
+ * field makes changes to the property value.
+ */
+ private boolean suppressValueChangePropagation = false;
+
+ /**
* Current source exception.
*/
private Buffered.SourceException currentBufferedSourceException = null;
@@ -220,6 +227,7 @@ public abstract class AbstractField extends AbstractComponent implements Field,
try {
// Commits the value to datasource.
+ suppressValueChangePropagation = true;
dataSource.setValue(newValue);
} catch (final Throwable e) {
@@ -231,6 +239,8 @@ public abstract class AbstractField extends AbstractComponent implements Field,
// Throws the source exception.
throw currentBufferedSourceException;
+ } finally {
+ suppressValueChangePropagation = false;
}
} else {
/* An invalid value and we don't allow them, throw the exception */
@@ -484,6 +494,7 @@ public abstract class AbstractField extends AbstractComponent implements Field,
try {
// Commits the value to datasource
+ suppressValueChangePropagation = true;
dataSource.setValue(newValue);
// The buffer is now unmodified
@@ -498,6 +509,8 @@ public abstract class AbstractField extends AbstractComponent implements Field,
// Throws the source exception
throw currentBufferedSourceException;
+ } finally {
+ suppressValueChangePropagation = false;
}
}
@@ -945,12 +958,16 @@ public abstract class AbstractField extends AbstractComponent implements Field,
* This method listens to data source value changes and passes the changes
* forwards.
*
+ * Changes are not forwarded to the listeners of the field during internal
+ * operations of the field to avoid duplicate notifications.
+ *
* @param event
* the value change event telling the data source contents have
* changed.
*/
public void valueChange(Property.ValueChangeEvent event) {
- if (isReadThrough() || !isModified()) {
+ if (!suppressValueChangePropagation
+ && (isReadThrough() || !isModified())) {
fireValueChange(false);
}
}
@@ -1228,7 +1245,7 @@ public abstract class AbstractField extends AbstractComponent implements Field,
@Override
public void handleAction(Object sender, Object target) {
- this.focusable.focus();
+ focusable.focus();
}
}
} \ No newline at end of file