Class TextFieldBase<TComponent extends TextFieldBase<TComponent,TValue>,TValue>
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<TComponent,TValue>
com.vaadin.flow.component.AbstractSinglePropertyField<TComponent,TValue>
com.vaadin.flow.component.textfield.TextFieldBase<TComponent,TValue>
- Type Parameters:
TComponent- Type of the component that extends from this classTValue- Type of the value of the extending component
- All Implemented Interfaces:
AttachNotifier,BlurNotifier<TComponent>,CompositionNotifier,DetachNotifier,Focusable<TComponent>,FocusNotifier<TComponent>,HasAriaLabel,HasElement,HasEnabled,HasHelper,HasLabel,HasPlaceholder,HasSize,HasStyle,HasValidation,HasValue<AbstractField.ComponentValueChangeEvent<TComponent,,TValue>, TValue> HasValueAndElement<AbstractField.ComponentValueChangeEvent<TComponent,,TValue>, TValue> InputNotifier,KeyNotifier,HasClearButton,HasPrefix,HasSuffix,HasTooltip,HasValidationProperties,InputField<AbstractField.ComponentValueChangeEvent<TComponent,,TValue>, TValue> HasAutocapitalize,HasAutocomplete,HasAutocorrect,HasValidator<TValue>,HasValueChangeMode,Serializable
- Direct Known Subclasses:
AbstractNumberField,BigDecimalField,EmailField,PasswordField,TextArea,TextField
public abstract class TextFieldBase<TComponent extends TextFieldBase<TComponent,TValue>,TValue>
extends AbstractSinglePropertyField<TComponent,TValue>
implements CompositionNotifier, Focusable<TComponent>, HasAriaLabel, HasAutocapitalize, HasAutocomplete, HasAutocorrect, HasClearButton, HasValidationProperties, HasValidator<TValue>, HasValueChangeMode, HasPlaceholder, HasPrefix, HasSuffix, InputNotifier, KeyNotifier, InputField<AbstractField.ComponentValueChangeEvent<TComponent,TValue>,TValue>
Internal class that provides base functionality for input field components,
such as
TextField. Not intended to be used publicly.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
AbstractField.ComponentValueChangeEvent<C extends Component,V> Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
BlurNotifier.BlurEvent<C extends Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
FocusNotifier.FocusEvent<C extends Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>> -
Field Summary
Fields inherited from interface com.vaadin.flow.component.textfield.HasAutocapitalize
AUTOCAPITALIZE_ATTRIBUTEFields inherited from interface com.vaadin.flow.component.textfield.HasAutocomplete
AUTOCOMPLETE_ATTRIBUTEFields inherited from interface com.vaadin.flow.component.textfield.HasAutocorrect
AUTOCORRECT_ATTRIBUTEFields inherited from interface com.vaadin.flow.data.value.HasValueChangeMode
DEFAULT_CHANGE_TIMEOUT -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddToInput(Component... components) Adds the given components as children of this component at the slot 'input'.protected voidaddToPrefix(Component... components) Adds the given components as children of this component at the slot 'prefix'.protected voidaddToSuffix(Component... components) Adds the given components as children of this component at the slot 'suffix'.Gets the aria-label of the component.Gets the aria-labelledby of the componentgetTitle()The text usually displayed in a tooltip popup when the mouse is over the field.Gets current value change mode of the component.intReturns the currently set timeout, for how oftenHasValue.ValueChangeEvents are triggered when the ValueChangeMode is set toValueChangeMode.LAZY, orValueChangeMode.TIMEOUT.booleanSpecify that this control should have input focus when the page loads.booleanSpecifies if the field value gets automatically selected when the field gains focus.booleanAlias forisRequiredIndicatorVisible()booleanGets whether the user is required to provide a value.voidsetAriaLabel(String ariaLabel) Set the aria-label of the component to the given text.voidsetAriaLabelledBy(String labelledBy) Set the aria-labelledby of the component.voidsetAutofocus(boolean autofocus) Sets the whether the component should automatically receive focus when the page loads.voidsetAutoselect(boolean autoselect) Set totrueto always have the field value automatically selected when the field gains focus,falseotherwise.voidSet the label of the component to the given text.voidsetRequired(boolean required) Alias forsetRequiredIndicatorVisible(boolean).voidsetRequiredIndicatorVisible(boolean required) Sets whether the user is required to provide a value.voidThe text usually displayed in a tooltip popup when the mouse is over the field.voidsetValueChangeMode(ValueChangeMode valueChangeMode) Sets new value change mode for the component.voidsetValueChangeTimeout(int valueChangeTimeout) Sets how oftenHasValue.ValueChangeEvents are triggered when the ValueChangeMode is set toValueChangeMode.LAZY, orValueChangeMode.TIMEOUT.Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEventMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEqualsMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.CompositionNotifier
addCompositionEndListener, addCompositionStartListener, addCompositionUpdateListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.textfield.HasAutocapitalize
getAutocapitalize, setAutocapitalizeMethods inherited from interface com.vaadin.flow.component.textfield.HasAutocomplete
getAutocomplete, setAutocompleteMethods inherited from interface com.vaadin.flow.component.textfield.HasAutocorrect
isAutocorrect, setAutocorrectMethods inherited from interface com.vaadin.flow.component.shared.HasClearButton
isClearButtonVisible, setClearButtonVisibleMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasHelper
getHelperComponent, getHelperText, setHelperComponent, setHelperTextMethods inherited from interface com.vaadin.flow.component.HasPlaceholder
getPlaceholder, setPlaceholderMethods inherited from interface com.vaadin.flow.component.shared.HasPrefix
getPrefixComponent, setPrefixComponentMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.shared.HasSuffix
getSuffixComponent, setSuffixComponentMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipMarkdown, setTooltipTextMethods inherited from interface com.vaadin.flow.component.HasValidation
setManualValidationMethods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties
getErrorMessage, isInvalid, setErrorMessage, setInvalidMethods inherited from interface com.vaadin.flow.data.binder.HasValidator
addValidationStatusChangeListener, getDefaultValidatorMethods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, clear, getEmptyValue, getOptionalValue, getValue, isEmpty, setValueMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, setReadOnlyMethods inherited from interface com.vaadin.flow.component.InputNotifier
addInputListenerMethods inherited from interface com.vaadin.flow.component.KeyNotifier
addKeyDownListener, addKeyDownListener, addKeyPressListener, addKeyPressListener, addKeyUpListener, addKeyUpListener
-
Method Details
-
getValueChangeMode
Gets current value change mode of the component.The default value is
ValueChangeMode.ON_CHANGE.- Specified by:
getValueChangeModein interfaceHasValueChangeMode- Returns:
- current value change mode of the component, or
nullif the value is not synchronized
-
setValueChangeMode
Description copied from interface:HasValueChangeModeSets new value change mode for the component.- Specified by:
setValueChangeModein interfaceHasValueChangeMode- Parameters:
valueChangeMode- new value change mode, ornullto disable the value synchronization
-
setValueChangeTimeout
public void setValueChangeTimeout(int valueChangeTimeout) Description copied from interface:HasValueChangeModeSets how oftenHasValue.ValueChangeEvents are triggered when the ValueChangeMode is set toValueChangeMode.LAZY, orValueChangeMode.TIMEOUT.Implementations should use
ValueChangeMode.applyChangeTimeout(ValueChangeMode, int, DomListenerRegistration).- Specified by:
setValueChangeTimeoutin interfaceHasValueChangeMode- Parameters:
valueChangeTimeout- the timeout in milliseconds of how oftenHasValue.ValueChangeEvents are triggered.
-
getValueChangeTimeout
public int getValueChangeTimeout()Description copied from interface:HasValueChangeModeReturns the currently set timeout, for how oftenHasValue.ValueChangeEvents are triggered when the ValueChangeMode is set toValueChangeMode.LAZY, orValueChangeMode.TIMEOUT.- Specified by:
getValueChangeTimeoutin interfaceHasValueChangeMode- Returns:
- the timeout in milliseconds of how often
HasValue.ValueChangeEvents are triggered.
-
setAutofocus
public void setAutofocus(boolean autofocus) Sets the whether the component should automatically receive focus when the page loads. Defaults tofalse.- Parameters:
autofocus-truecomponent should automatically receive focus
-
isAutofocus
public boolean isAutofocus()Specify that this control should have input focus when the page loads.- Returns:
- the
autofocusproperty from the webcomponent
-
getTitle
The text usually displayed in a tooltip popup when the mouse is over the field.- Returns:
- the
titleproperty from the webcomponent
-
setTitle
The text usually displayed in a tooltip popup when the mouse is over the field.- Parameters:
title- the String value to set
-
isAutoselect
public boolean isAutoselect()Specifies if the field value gets automatically selected when the field gains focus.- Returns:
trueif autoselect is active,falseotherwise
-
setAutoselect
public void setAutoselect(boolean autoselect) Set totrueto always have the field value automatically selected when the field gains focus,falseotherwise.- Parameters:
autoselect-trueto set auto select on,falseotherwise
-
setRequiredIndicatorVisible
public void setRequiredIndicatorVisible(boolean required) Sets whether the user is required to provide a value. When required, an indicator appears next to the label and the field invalidates if the value is cleared.NOTE: The required indicator is only visible when the field has a label, see
setLabel(String).- Specified by:
setRequiredIndicatorVisiblein interfaceHasValue<TComponent extends TextFieldBase<TComponent,TValue>, TValue> - Specified by:
setRequiredIndicatorVisiblein interfaceHasValueAndElement<TComponent extends TextFieldBase<TComponent,TValue>, TValue> - Parameters:
required-trueto make the field required,falseotherwise
-
isRequiredIndicatorVisible
public boolean isRequiredIndicatorVisible()Gets whether the user is required to provide a value.- Specified by:
isRequiredIndicatorVisiblein interfaceHasValue<TComponent extends TextFieldBase<TComponent,TValue>, TValue> - Specified by:
isRequiredIndicatorVisiblein interfaceHasValueAndElement<TComponent extends TextFieldBase<TComponent,TValue>, TValue> - Returns:
trueif the field is required,falseotherwise- See Also:
-
setRequired
public void setRequired(boolean required) Alias forsetRequiredIndicatorVisible(boolean).- Parameters:
required-trueto make the field required,falseotherwise
-
isRequired
public boolean isRequired()Alias forisRequiredIndicatorVisible()- Returns:
trueif the field is required,falseotherwise
-
setLabel
Description copied from interface:HasLabelSet the label of the component to the given text. -
setAriaLabel
Description copied from interface:HasAriaLabelSet the aria-label of the component to the given text.This method should not be used if
HasAriaLabel.setAriaLabelledBy(String)is also used. If both attributes are present, aria-labelledby will take precedence over aria-label.- Specified by:
setAriaLabelin interfaceHasAriaLabel- Parameters:
ariaLabel- the aria-label text to set ornullto clear
-
getAriaLabel
Description copied from interface:HasAriaLabelGets the aria-label of the component.- Specified by:
getAriaLabelin interfaceHasAriaLabel- Returns:
- an optional aria-label of the component if no aria-label has been set
-
setAriaLabelledBy
Description copied from interface:HasAriaLabelSet the aria-labelledby of the component. The value must be a valid id attribute of another element that labels the component. The label element must be in the same DOM scope of the component, otherwise screen readers may fail to announce the label content properly.This method should not be used if
HasAriaLabel.setAriaLabel(String)is also used. If both attributes are present, aria-labelledby will take precedence over aria-label.- Specified by:
setAriaLabelledByin interfaceHasAriaLabel- Parameters:
labelledBy- the string with the id of the element that will be used as label ornullto clear
-
getAriaLabelledBy
Description copied from interface:HasAriaLabelGets the aria-labelledby of the component- Specified by:
getAriaLabelledByin interfaceHasAriaLabel- Returns:
- an optional aria-labelledby of the component if no aria-labelledby has been set
-
addToPrefix
Adds the given components as children of this component at the slot 'prefix'.- Parameters:
components- The components to add.- See Also:
-
addToInput
Adds the given components as children of this component at the slot 'input'.- Parameters:
components- The components to add.- See Also:
-
addToSuffix
Adds the given components as children of this component at the slot 'suffix'.- Parameters:
components- The components to add.- See Also:
-