From 54aac82d4e87af786a4b8d29a83291ab350f1643 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Fri, 9 Dec 2011 13:31:08 +0000 Subject: [PATCH] #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 --- .../terminal/gwt/client/ui/VTextField.java | 36 ++++++++----------- 1 file 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 -- 2.39.5