summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2011-12-09 13:31:08 +0000
committerLeif Åstrand <leif@vaadin.com>2011-12-09 13:31:08 +0000
commit54aac82d4e87af786a4b8d29a83291ab350f1643 (patch)
treee729c08b67813bdb75b4f1cea79b13e54b39564d /src
parent9e37b2b4e65c1b2926d300e6fdd6b9bd0b66ef38 (diff)
downloadvaadin-framework-54aac82d4e87af786a4b8d29a83291ab350f1643.tar.gz
vaadin-framework-54aac82d4e87af786a4b8d29a83291ab350f1643.zip
#8035 - More generic fix based on review
Don't send a text change message in cases where a value change has already been sent or is about to get sent svn changeset:22359/svn branch:6.7
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTextField.java36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextField.java b/src/com/vaadin/terminal/gwt/client/ui/VTextField.java
index a4038b67ac..f059e0cea5 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTextField.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTextField.java
@@ -138,18 +138,28 @@ public class VTextField extends TextBoxBase implements Paintable, Field,
return lastTextChangeString;
}
- private boolean communicateTextValueToServer() {
+ private void communicateTextValueToServer() {
String text = getText();
if (prompting) {
// Input prompt visible, text is actually ""
text = "";
}
if (!text.equals(getLastCommunicatedString())) {
+ if (text.equals(valueBeforeEdit)) {
+ /*
+ * Value change for the current text has been enqueued, but we
+ * can't know that it has been sent to the server. Ensure that
+ * all pending changes are sent now. Sending a value change
+ * without a text change will simulate a TextChangeEvent on the
+ * server.
+ */
+ client.sendPendingVariableChanges();
+ } else {
+ // Default case - just send an immediate text change message
+ client.updateVariable(id, VAR_CUR_TEXT, text, true);
+ }
lastTextChangeString = text;
- client.updateVariable(id, VAR_CUR_TEXT, text, true);
- return true;
}
- return false;
}
private Timer textChangeEventTrigger = new Timer() {
@@ -158,10 +168,7 @@ public class VTextField extends TextBoxBase implements Paintable, Field,
public void run() {
if (isAttached()) {
updateCursorPosition();
- boolean textChanged = communicateTextValueToServer();
- if (textChanged) {
- client.sendPendingVariableChanges();
- }
+ communicateTextValueToServer();
scheduled = false;
}
}
@@ -587,20 +594,7 @@ public class VTextField extends TextBoxBase implements Paintable, Field,
}
public void onBeforeShortcutAction(Event e) {
- // Remember current value to detect changes
- String oldValue = valueBeforeEdit;
-
valueChange(false);
-
- /*
- * The valueChange method updates valueBeforeEdit when a "text" variable
- * is sent. This will cause a text change event to be simulated on the
- * server. In that case, we should avoid sending the same text as a
- * normal text change event. (#8035)
- */
- if (oldValue != valueBeforeEdit) {
- lastTextChangeString = valueBeforeEdit;
- }
}
// Here for backward compatibility; to be moved to TextArea