]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merge of (#9940) to Vaadin 7
authorJohn Ahlroos <john@vaadin.com>
Wed, 20 Feb 2013 07:44:43 +0000 (09:44 +0200)
committerJohn Ahlroos <john@vaadin.com>
Wed, 20 Feb 2013 07:44:43 +0000 (09:44 +0200)
Change-Id: Ie2e53c8cdba20c8265fa04e35e9469b39b21d43e

client/src/com/vaadin/client/ui/VTextField.java
uitest/src/com/vaadin/tests/components/textfield/TextFieldMaxLengthRemovedFromDOM.html [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/textfield/TextFieldMaxLengthRemovedFromDOM.java [new file with mode: 0644]

index 1229eda093e11bc2510b58cc713385f9b24b2c6a..0fbed0dd90f32a522e1552b0883b66515098f64a 100644 (file)
@@ -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 (file)
index 0000000..45c7e0f
--- /dev/null
@@ -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 (file)
index 0000000..61993de
--- /dev/null
@@ -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;
+    }
+
+}