diff options
author | Matti Hosio <mhosio@vaadin.com> | 2014-12-10 17:01:33 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-12-10 16:06:34 +0000 |
commit | 775276d4a987844fbbb88730f0eb11e285ae6e09 (patch) | |
tree | 0e1b26980eb9f2307e480f264b4e1ca62756fb88 /server/src/com/vaadin/ui/AbstractTextField.java | |
parent | a0e1fe4b61ff2b2bf1e35f983e1926b6fa694020 (diff) | |
download | vaadin-framework-775276d4a987844fbbb88730f0eb11e285ae6e09.tar.gz vaadin-framework-775276d4a987844fbbb88730f0eb11e285ae6e09.zip |
Declarative support for AbstractTextField (#7749)
Change-Id: Ice244cd73825bde44fe02cf3d4b53d4eff5a5c35
Diffstat (limited to 'server/src/com/vaadin/ui/AbstractTextField.java')
-rw-r--r-- | server/src/com/vaadin/ui/AbstractTextField.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java index 9293d38119..31672a1f39 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,54 @@ public abstract class AbstractTextField extends AbstractField<String> implements removeBlurListener(listener); } + /* + * (non-Javadoc) + * + * @see + * com.vaadin.ui.AbstractField#synchronizeFromDesign(org.jsoup.nodes.Element + * , com.vaadin.ui.declarative.DesignContext) + */ + @Override + public void synchronizeFromDesign(Element design, + DesignContext designContext) { + super.synchronizeFromDesign(design, designContext); + AbstractTextField def = designContext.getDefaultInstance(this + .getClass()); + Attributes attr = design.attributes(); + int maxLength = DesignAttributeHandler.readAttribute("maxlength", attr, + def.getMaxLength(), Integer.class); + setMaxLength(maxLength); + } + + /* + * (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 + return customAttributes; + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.ui.AbstractField#synchronizeToDesign(org.jsoup.nodes.Element, + * com.vaadin.ui.declarative.DesignContext) + */ + @Override + public void synchronizeToDesign(Element design, DesignContext designContext) { + super.synchronizeToDesign(design, designContext); + AbstractTextField def = designContext.getDefaultInstance(this + .getClass()); + Attributes attr = design.attributes(); + DesignAttributeHandler.writeAttribute("maxlength", attr, + getMaxLength(), def.getMaxLength(), Integer.class); + } + } |