From: John Ahlroos Date: Wed, 20 Feb 2013 07:44:43 +0000 (+0200) Subject: Merge of (#9940) to Vaadin 7 X-Git-Tag: 7.0.2~44 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2788b5192330a8ac8169571b592be33972c3b016;p=vaadin-framework.git Merge of (#9940) to Vaadin 7 Change-Id: Ie2e53c8cdba20c8265fa04e35e9469b39b21d43e --- diff --git a/client/src/com/vaadin/client/ui/VTextField.java b/client/src/com/vaadin/client/ui/VTextField.java index 1229eda093..0fbed0dd90 100644 --- a/client/src/com/vaadin/client/ui/VTextField.java +++ b/client/src/com/vaadin/client/ui/VTextField.java @@ -272,19 +272,16 @@ public class VTextField extends TextBoxBase implements Field, ChangeHandler, /** For internal use only. May be removed or replaced in the future. */ public void setMaxLength(int newMaxLength) { - if (newMaxLength >= 0 && newMaxLength != maxLength) { - maxLength = newMaxLength; - updateMaxLength(maxLength); - } else if (maxLength != -1) { - maxLength = -1; - updateMaxLength(maxLength); + if (newMaxLength == maxLength) { + return; } - + maxLength = newMaxLength; + updateMaxLength(maxLength); } /** - * This method is reponsible for updating the DOM or otherwise ensuring that - * the given max length is enforced. Called when the max length for the + * This method is responsible for updating the DOM or otherwise ensuring + * that the given max length is enforced. Called when the max length for the * field has changed. * * @param maxLength diff --git a/uitest/src/com/vaadin/tests/components/textfield/TextFieldMaxLengthRemovedFromDOM.html b/uitest/src/com/vaadin/tests/components/textfield/TextFieldMaxLengthRemovedFromDOM.html new file mode 100644 index 0000000000..45c7e0f2c8 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/textfield/TextFieldMaxLengthRemovedFromDOM.html @@ -0,0 +1,51 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.textfield.TextFieldMaxLengthRemovedFromDOM?restartApplication
assertAttributevaadin=runcomvaadintestscomponentstextfieldTextFieldMaxLengthRemovedFromDOM::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTextField[0]@maxlength11
mouseClickvaadin=runcomvaadintestscomponentstextfieldTextFieldMaxLengthRemovedFromDOM::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTextField[0]118,13
assertAttributevaadin=runcomvaadintestscomponentstextfieldTextFieldMaxLengthRemovedFromDOM::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTextField[0]@maxlength11
typevaadin=runcomvaadintestscomponentstextfieldTextFieldMaxLengthRemovedFromDOM::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTextField[0]hello
mouseClickvaadin=runcomvaadintestscomponentstextfieldTextFieldMaxLengthRemovedFromDOM::/VVerticalLayout[0]/domChild[0]/domChild[1]172,60
assertAttributevaadin=runcomvaadintestscomponentstextfieldTextFieldMaxLengthRemovedFromDOM::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTextField[0]@maxlength11
+ + diff --git a/uitest/src/com/vaadin/tests/components/textfield/TextFieldMaxLengthRemovedFromDOM.java b/uitest/src/com/vaadin/tests/components/textfield/TextFieldMaxLengthRemovedFromDOM.java new file mode 100644 index 0000000000..61993de107 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/textfield/TextFieldMaxLengthRemovedFromDOM.java @@ -0,0 +1,37 @@ +package com.vaadin.tests.components.textfield; + +import com.vaadin.event.FieldEvents; +import com.vaadin.event.FieldEvents.FocusEvent; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.TextField; + +public class TextFieldMaxLengthRemovedFromDOM extends TestBase { + + @Override + protected void setup() { + final TextField tf = new TextField(); + tf.setMaxLength(11); + tf.setRequired(true); + tf.setImmediate(true); + addComponent(tf); + + tf.addListener(new FieldEvents.FocusListener() { + + public void focus(FocusEvent event) { + // Resetting Max length should not remove maxlength attribute + tf.setMaxLength(11); + } + }); + } + + @Override + protected String getDescription() { + return "Maxlength attribute should not dissappear from the DOM when I focus the text field."; + } + + @Override + protected Integer getTicketNumber() { + return 9940; + } + +}