summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Alhroos <john.ahlroos@itmill.com>2011-06-23 10:55:10 +0000
committerJohn Alhroos <john.ahlroos@itmill.com>2011-06-23 10:55:10 +0000
commit809c1778c8094e53bd1b6674b4507043a2b16f5b (patch)
tree6b84fbd82969d8c722006d37eda74b1895ff436f /src
parent2d585453bbf6dc437a74e760645a4405184edffc (diff)
downloadvaadin-framework-809c1778c8094e53bd1b6674b4507043a2b16f5b.tar.gz
vaadin-framework-809c1778c8094e53bd1b6674b4507043a2b16f5b.zip
Fix for #6588
svn changeset:19527/svn branch:6.6
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/ui/AbstractTextField.java48
1 files changed, 45 insertions, 3 deletions
diff --git a/src/com/vaadin/ui/AbstractTextField.java b/src/com/vaadin/ui/AbstractTextField.java
index 4ed76d367b..622b8d18d9 100644
--- a/src/com/vaadin/ui/AbstractTextField.java
+++ b/src/com/vaadin/ui/AbstractTextField.java
@@ -1,4 +1,4 @@
-/*
+/*
@ITMillApache2LicenseForJavaFiles@
*/
@@ -123,7 +123,20 @@ public abstract class AbstractTextField extends AbstractField implements
throw new IllegalStateException(
"Null values are not allowed if the null-representation is null");
}
- target.addVariable(this, "text", value);
+
+ if (requestRepaintInTextChangeEvent && !valueChangeInTextChangeEvent) {
+ /*
+ * If the repaint occurred in a text change event then we do not
+ * want to send back the old value since it will just overwrite the
+ * typed value so we send the last known value instead which is
+ * updated by the text change event.
+ */
+ target.addVariable(this, "text", lastKnownTextContent);
+ } else {
+ target.addVariable(this, "text", value);
+ }
+ requestRepaintInTextChangeEvent = false;
+ valueChangeInTextChangeEvent = false;
if (selectionPosition != -1) {
target.addAttribute("selpos", selectionPosition);
@@ -171,6 +184,22 @@ public abstract class AbstractTextField extends AbstractField implements
}
}
+ /**
+ * Flag for monitoring if a repaint gets requested in a text change event
+ */
+ private boolean requestRepaintInTextChangeEvent = false;
+
+ @Override
+ public void requestRepaint() {
+ if (textChangeEventPending) {
+ /*
+ * Textchange event listener triggered this repaint
+ */
+ requestRepaintInTextChangeEvent = true;
+ }
+ super.requestRepaint();
+ }
+
@Override
public void changeVariables(Object source, Map<String, Object> variables) {
changingVariables = true;
@@ -438,13 +467,26 @@ public abstract class AbstractTextField extends AbstractField implements
private void firePendingTextChangeEvent() {
if (textChangeEventPending) {
- textChangeEventPending = false;
fireEvent(new TextChangeEventImpl(this));
+ textChangeEventPending = false;
}
}
+ /**
+ * Flag for monitoring if the value got changed in a TextChangeEvent
+ * listener
+ */
+ protected boolean valueChangeInTextChangeEvent = false;
+
@Override
protected void setInternalValue(Object newValue) {
+ if (textChangeEventPending) {
+ /*
+ * Value changed in a TextChangeEvent listener
+ */
+ valueChangeInTextChangeEvent = true;
+ }
+
if (changingVariables && !textChangeEventPending) {
/*
* Fire a "simulated" text change event before value change event if