T - field value type@Tag(value="vaadin-custom-field") @HtmlImport(value="frontend://bower_components/vaadin-custom-field/src/vaadin-custom-field.html") public abstract class CustomField<T> extends com.vaadin.flow.component.AbstractField<CustomField<T>,T> implements com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasValidation, com.vaadin.flow.component.Focusable<CustomField>
HasValue whose UI content can be constructed by the user, enabling
the creation of e.g. form fields by composing Vaadin components.
Customization of both the visual presentation and the logic of the field is
possible.
Subclasses must implement generateModelValue() and AbstractFieldsetPresentationValue(Object).
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V>com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>| Constructor and Description |
|---|
CustomField()
Default constructor.
|
CustomField(T defaultValue)
Constructs a new custom field.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
add(com.vaadin.flow.component.Component... components)
Adds the given components as children of this component.
|
protected abstract T |
generateModelValue()
This method should return the value of the field, based on value of the internal fields.
|
String |
getErrorMessage() |
String |
getLabel()
Gets the label for the field.
|
boolean |
isInvalid()
This property is set to true when the control value is invalid.
|
protected void |
remove(com.vaadin.flow.component.Component... components)
Removes the given child components from this component.
|
void |
setErrorMessage(String errorMessage) |
void |
setInvalid(boolean invalid)
This property is set to true when the control value is invalid.
|
void |
setLabel(String label)
Sets the label for the field.
|
protected abstract void |
setPresentationValue(T newPresentationValue)
This method should be implemented to set the value of the fields contained
in this custom field according to the value of the parameter.
|
protected void |
updateValue()
Regenerates the value by calling
generateModelValue() and updates the model. |
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEqualsaddListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getUI, hasListener, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetHeight, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, setHeight, setHeightFull, setMaxHeight, setMaxWidth, setMinHeight, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidthFulladdFocusShortcut, blur, focus, getTabIndex, setTabIndexpublic CustomField()
public CustomField(T defaultValue)
defaultValue - The initial value for the field. Will also be used by AbstractField.getEmptyValue().AbstractField.AbstractField(Object)protected abstract T generateModelValue()
protected abstract void setPresentationValue(T newPresentationValue)
setPresentationValue in class com.vaadin.flow.component.AbstractField<CustomField<T>,T>newPresentationValue - The new presentation value.protected void updateValue()
generateModelValue() and updates the model.
If the value is different than the current one, a ValueChangeEvent will be generated with ValueChangeEvent#isFromClient() set to true
This method is called when the webcomponent generates a changed event, typically in response to a change made by the user in one of the contained fields.
Custom implementations of this method must call AbstractField.setModelValue(Object, boolean) with the updated model value.
Subclasses can call this method when the model value needs to be regenerated and updated.
protected void add(com.vaadin.flow.component.Component... components)
components - the components to addprotected void remove(com.vaadin.flow.component.Component... components)
components - the components to removeIllegalArgumentException - if any of the components is not a child of this component@Synchronize(property="invalid",
value="invalid-changed")
public boolean isInvalid()
This property is set to true when the control value is invalid.
This property is synchronized automatically from client side when a 'invalid-changed' event happens.
isInvalid in interface com.vaadin.flow.component.HasValidationinvalid property from the webcomponentpublic void setInvalid(boolean invalid)
This property is set to true when the control value is invalid.
setInvalid in interface com.vaadin.flow.component.HasValidationinvalid - the boolean value to setpublic void setErrorMessage(String errorMessage)
setErrorMessage in interface com.vaadin.flow.component.HasValidationpublic String getErrorMessage()
getErrorMessage in interface com.vaadin.flow.component.HasValidationpublic String getLabel()
label property from the webcomponentpublic void setLabel(String label)
label - value for the label property in the webcomponentCopyright © 2018–2019 Vaadin Ltd. All rights reserved.