From eb9eef97e527d366f25b9dffd4b992d0e9a0ca65 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 13 Aug 2012 10:11:49 +0000 Subject: Enforce max length when max length changes (#9199) svn changeset:24157/svn branch:6.8 --- .../vaadin/terminal/gwt/client/ui/VTextArea.java | 28 ++++++++++++---------- 1 file 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(); } } -- cgit v1.2.3