diff options
author | John Ahlroos <john@vaadin.com> | 2013-02-20 09:44:43 +0200 |
---|---|---|
committer | John Ahlroos <john@vaadin.com> | 2013-02-20 09:44:43 +0200 |
commit | 2788b5192330a8ac8169571b592be33972c3b016 (patch) | |
tree | 4bc133c3d8ca0dd0224ba5d9229d210a97db060c | |
parent | 74557919f3000f172245479e7200311a136fe258 (diff) | |
download | vaadin-framework-2788b5192330a8ac8169571b592be33972c3b016.tar.gz vaadin-framework-2788b5192330a8ac8169571b592be33972c3b016.zip |
Merge of (#9940) to Vaadin 7
Change-Id: Ie2e53c8cdba20c8265fa04e35e9469b39b21d43e
3 files changed, 94 insertions, 9 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.textfield.TextFieldMaxLengthRemovedFromDOM?restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertAttribute</td> + <td>vaadin=runcomvaadintestscomponentstextfieldTextFieldMaxLengthRemovedFromDOM::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTextField[0]@maxlength</td> + <td>11</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstextfieldTextFieldMaxLengthRemovedFromDOM::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTextField[0]</td> + <td>118,13</td> +</tr> +<tr> + <td>assertAttribute</td> + <td>vaadin=runcomvaadintestscomponentstextfieldTextFieldMaxLengthRemovedFromDOM::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTextField[0]@maxlength</td> + <td>11</td> +</tr> +<tr> + <td>type</td> + <td>vaadin=runcomvaadintestscomponentstextfieldTextFieldMaxLengthRemovedFromDOM::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTextField[0]</td> + <td>hello</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstextfieldTextFieldMaxLengthRemovedFromDOM::/VVerticalLayout[0]/domChild[0]/domChild[1]</td> + <td>172,60</td> +</tr> +<tr> + <td>assertAttribute</td> + <td>vaadin=runcomvaadintestscomponentstextfieldTextFieldMaxLengthRemovedFromDOM::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTextField[0]@maxlength</td> + <td>11</td> +</tr> +</tbody></table> +</body> +</html> 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; + } + +} |