diff options
author | Artur Signell <artur.signell@itmill.com> | 2012-08-13 10:11:49 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2012-08-13 10:11:49 +0000 |
commit | eb9eef97e527d366f25b9dffd4b992d0e9a0ca65 (patch) | |
tree | 6d5e3b386c8688e68cb08158f96d09ddfa5d7836 | |
parent | 856a68cbdb93d8ca8b6b45b604f606bfbb138b28 (diff) | |
download | vaadin-framework-eb9eef97e527d366f25b9dffd4b992d0e9a0ca65.tar.gz vaadin-framework-eb9eef97e527d366f25b9dffd4b992d0e9a0ca65.zip |
Enforce max length when max length changes (#9199)
svn changeset:24157/svn branch:6.8
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/VTextArea.java | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java b/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java index 4ab27646ed..a90a5679d9 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java @@ -63,18 +63,6 @@ public class VTextArea extends VTextField { enforceMaxLength(); } - private void enforceMaxLength() { - if (getMaxLength() >= 0) { - Scheduler.get().scheduleDeferred(new Command() { - public void execute() { - if (getText().length() > getMaxLength()) { - setText(getText().substring(0, getMaxLength())); - } - } - }); - } - } - public void onChange(ChangeEvent event) { // Opera does not support paste events so this enforces max length // for Opera. @@ -83,6 +71,18 @@ public class VTextArea extends VTextField { } + protected void enforceMaxLength() { + if (getMaxLength() >= 0) { + Scheduler.get().scheduleDeferred(new Command() { + public void execute() { + if (getText().length() > getMaxLength()) { + setText(getText().substring(0, getMaxLength())); + } + } + }); + } + } + protected boolean browserSupportsMaxLengthAttribute() { BrowserInfo info = BrowserInfo.get(); if (info.isFirefox() && info.isBrowserVersionNewerOrEqual(4, 0)) { @@ -105,7 +105,9 @@ public class VTextArea extends VTextField { if (browserSupportsMaxLengthAttribute) { super.updateMaxLength(maxLength); } else { - // Handled automatically by MaxLengthHandler + // Events handled by MaxLengthHandler. This call enforces max length + // when the max length value has changed + enforceMaxLength(); } } |