diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2011-10-07 13:31:44 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2011-10-07 13:31:44 +0000 |
commit | 3e198eae20d1dfc8b136e58a842393ca49eafc83 (patch) | |
tree | f55aa63fef2046c70e7c4662788ef8bb2391b565 /src/com/vaadin/ui | |
parent | c380aabda7019369abb29d3cbdab0daf777dd16b (diff) | |
download | vaadin-framework-3e198eae20d1dfc8b136e58a842393ca49eafc83.tar.gz vaadin-framework-3e198eae20d1dfc8b136e58a842393ca49eafc83.zip |
#6588 quick fix, still need to re-evaluate and test the solution
svn changeset:21650/svn branch:6.7
Diffstat (limited to 'src/com/vaadin/ui')
-rw-r--r-- | src/com/vaadin/ui/AbstractTextField.java | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/src/com/vaadin/ui/AbstractTextField.java b/src/com/vaadin/ui/AbstractTextField.java index 4ed76d367b..62904330c2 100644 --- a/src/com/vaadin/ui/AbstractTextField.java +++ b/src/com/vaadin/ui/AbstractTextField.java @@ -54,7 +54,8 @@ public abstract class AbstractTextField extends AbstractField implements private String inputPrompt = null; /** - * The text content when the last messages to the server was sent. + * The text content when the last messages to the server was sent. Cleared + * when value is changed. */ private String lastKnownTextContent; @@ -136,6 +137,17 @@ public abstract class AbstractTextField extends AbstractField implements getTextChangeEventMode().toString()); target.addAttribute(VTextField.ATTR_TEXTCHANGE_TIMEOUT, getTextChangeTimeout()); + if (lastKnownTextContent != null) { + /* + * The field has be repainted for some reason (e.g. caption, + * size, stylename), but the value has not been changed since + * the last text change event. Let the client side know about + * the value the server side knows. Client side may then ignore + * the actual value, depending on its state. + */ + target.addAttribute( + VTextField.ATTR_NO_VALUE_CHANGE_BETWEEN_PAINTS, true); + } } } @@ -446,6 +458,18 @@ public abstract class AbstractTextField extends AbstractField implements @Override protected void setInternalValue(Object newValue) { if (changingVariables && !textChangeEventPending) { + + /* + * TODO check for possible (minor?) issue (not tested) + * + * -field with e.g. PropertyFormatter. + * + * -TextChangeListener and it changes value. + * + * -if formatter again changes the value, do we get an extra + * simulated text change event ? + */ + /* * Fire a "simulated" text change event before value change event if * change is coming from the client side. @@ -467,12 +491,34 @@ public abstract class AbstractTextField extends AbstractField implements lastKnownTextContent = newValue.toString(); textChangeEventPending = true; } - firePendingTextChangeEvent(); } + + /* + * Reset lastKnownTextContent field on value change. We know the value + * now. + */ + lastKnownTextContent = null; super.setInternalValue(newValue); } + @Override + public void setValue(Object newValue) throws ReadOnlyException, + ConversionException { + super.setValue(newValue); + /* + * Make sure w reset lastKnownTextContent field on value change. The + * clearing must happen here as well because TextChangeListener can + * revert the original value. Client must respect the value in this + * case. AbstractField optimizes value change if the existing value is + * reset. Also we need to force repaint if the flag is on. + */ + if(lastKnownTextContent != null) { + lastKnownTextContent = null; + requestRepaint(); + } + } + private void handleInputEventTextChange(Map<String, Object> variables) { /* * TODO we could vastly optimize the communication of values by using |