summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui/AbstractTextField.java
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2014-12-18 18:30:09 +0200
committerLeif Åstrand <leif@vaadin.com>2014-12-18 18:30:09 +0200
commite3d0fbbab68f9ef8642a975741d9f576993b1f38 (patch)
tree5711a31c5af1d3773a86b4d25c9f8064aa435ecc /server/src/com/vaadin/ui/AbstractTextField.java
parent434fb5bf5cf62490686367e9193b7898077bbd44 (diff)
parent68eec666b55c42b4a55235c00bc78f6212eb2062 (diff)
downloadvaadin-framework-e3d0fbbab68f9ef8642a975741d9f576993b1f38.tar.gz
vaadin-framework-e3d0fbbab68f9ef8642a975741d9f576993b1f38.zip
Merge remote-tracking branch 'origin/master' into grid
Change-Id: Ic7629f9cedb3c948edf4f63c678ca499e3d52805
Diffstat (limited to 'server/src/com/vaadin/ui/AbstractTextField.java')
-rw-r--r--server/src/com/vaadin/ui/AbstractTextField.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java
index ea0372bc8c..93025ac0fd 100644
--- a/server/src/com/vaadin/ui/AbstractTextField.java
+++ b/server/src/com/vaadin/ui/AbstractTextField.java
@@ -16,8 +16,12 @@
package com.vaadin.ui;
+import java.util.Collection;
import java.util.Map;
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+
import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener;
import com.vaadin.event.FieldEvents.BlurNotifier;
@@ -31,6 +35,8 @@ import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.shared.ui.textfield.AbstractTextFieldState;
import com.vaadin.shared.ui.textfield.TextFieldConstants;
+import com.vaadin.ui.declarative.DesignAttributeHandler;
+import com.vaadin.ui.declarative.DesignContext;
public abstract class AbstractTextField extends AbstractField<String> implements
BlurNotifier, FocusNotifier, TextChangeNotifier, LegacyComponent {
@@ -757,4 +763,51 @@ public abstract class AbstractTextField extends AbstractField<String> implements
removeBlurListener(listener);
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.ui.AbstractField#readDesign(org.jsoup.nodes.Element ,
+ * com.vaadin.ui.declarative.DesignContext)
+ */
+ @Override
+ public void readDesign(Element design, DesignContext designContext) {
+ super.readDesign(design, designContext);
+ Attributes attr = design.attributes();
+ if (attr.hasKey("maxlength")) {
+ setMaxLength(DesignAttributeHandler.readAttribute("maxlength",
+ attr, Integer.class));
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.ui.AbstractField#getCustomAttributes()
+ */
+ @Override
+ protected Collection<String> getCustomAttributes() {
+ Collection<String> customAttributes = super.getCustomAttributes();
+ customAttributes.add("maxlength");
+ customAttributes.add("max-length"); // to prevent this appearing in
+ // output
+ customAttributes.add("cursor-position");
+ return customAttributes;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.ui.AbstractField#writeDesign(org.jsoup.nodes.Element,
+ * com.vaadin.ui.declarative.DesignContext)
+ */
+ @Override
+ public void writeDesign(Element design, DesignContext designContext) {
+ super.writeDesign(design, designContext);
+ AbstractTextField def = (AbstractTextField) designContext
+ .getDefaultInstance(this);
+ Attributes attr = design.attributes();
+ DesignAttributeHandler.writeAttribute("maxlength", attr,
+ getMaxLength(), def.getMaxLength(), Integer.class);
+ }
+
}