diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2011-10-13 13:56:02 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2011-10-13 13:56:02 +0000 |
commit | 1fed0795cbfb0a81f3cf273c7445614c23a312da (patch) | |
tree | 567638370a81f73c3b00f792426bc48cd01dd033 | |
parent | 9b51b83532b3dcdf182279464701da3064cd2389 (diff) | |
download | vaadin-framework-1fed0795cbfb0a81f3cf273c7445614c23a312da.tar.gz vaadin-framework-1fed0795cbfb0a81f3cf273c7445614c23a312da.zip |
#6588, #7776 : fine tuned fix with properties that modify value. ValueChange event is now postponed until "commit phase" is over. Internal flags shouldn't now get messed up in case value change listener again changes the value.
svn changeset:21706/svn branch:6.7
-rw-r--r-- | src/com/vaadin/ui/AbstractField.java | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/com/vaadin/ui/AbstractField.java b/src/com/vaadin/ui/AbstractField.java index 3619fbfdb3..7899569ea8 100644 --- a/src/com/vaadin/ui/AbstractField.java +++ b/src/com/vaadin/ui/AbstractField.java @@ -277,11 +277,13 @@ public abstract class AbstractField extends AbstractComponent implements Field, repaintNeeded = true; } - if (repaintNeeded) { + if (valueWasModifiedByDataSourceDuringCommit) { + valueWasModifiedByDataSourceDuringCommit = false; + fireValueChange(false); + } else if (repaintNeeded) { requestRepaint(); } - valueWasModifiedByDataSourceDuringCommit = false; } /* @@ -533,14 +535,17 @@ public abstract class AbstractField extends AbstractComponent implements Field, requestRepaint(); } - if (!valueWasModifiedByDataSourceDuringCommit) { - // Fires the value change - fireValueChange(repaintIsNotNeeded); - } else { - // value change event already fired in valueChange() - valueWasModifiedByDataSourceDuringCommit = false; - + if (valueWasModifiedByDataSourceDuringCommit) { + /* + * Value was modified by datasource. Force repaint even if + * repaint was not requested. + */ + valueWasModifiedByDataSourceDuringCommit = repaintIsNotNeeded = false; } + + // Fires the value change + fireValueChange(repaintIsNotNeeded); + } } @@ -1018,20 +1023,24 @@ public abstract class AbstractField extends AbstractComponent implements Field, * Property (or chained property like PropertyFormatter) now * reports different value than the one the field has just * committed to it. In this case we respect the property - * value, fire value change listeners and repaint the field. + * value. + * + * Still, we don't fire value change yet, but instead + * postpone it until "commit" is done. See setValue(Object, + * boolean) and commit(). */ readValueFromProperty(event); valueWasModifiedByDataSourceDuringCommit = true; } } else if (!isModified()) { readValueFromProperty(event); + fireValueChange(false); } } } private void readValueFromProperty(Property.ValueChangeEvent event) { setInternalValue(event.getProperty().getValue()); - fireValueChange(false); } @Override |