Class TextFieldBase<TComponent extends TextFieldBase<TComponent,TValue>,TValue>
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<C,T>
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
,HasClientValidation
,HasPrefix
,HasSuffix
,HasTooltip
,HasValidationProperties
,InputField<AbstractField.ComponentValueChangeEvent<TComponent,
,TValue>, TValue> HasAutocapitalize
,HasAutocomplete
,HasAutocorrect
,HasPrefixAndSuffix
,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, HasClientValidation, HasPrefixAndSuffix, HasValidationProperties, HasValidator<TValue>, HasValueChangeMode, HasPlaceholder, 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.shared.HasClientValidation
HasClientValidation.ClientValidatedEvent
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_ATTRIBUTE
Fields inherited from interface com.vaadin.flow.component.textfield.HasAutocomplete
AUTOCOMPLETE_ATTRIBUTE
Fields inherited from interface com.vaadin.flow.component.textfield.HasAutocorrect
AUTOCORRECT_ATTRIBUTE
Fields inherited from interface com.vaadin.flow.data.value.HasValueChangeMode
DEFAULT_CHANGE_TIMEOUT
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addToInput
(Component... components) Adds the given components as children of this component at the slot 'input'.protected void
addToPrefix
(Component... components) Adds the given components as children of this component at the slot 'prefix'.protected void
addToSuffix
(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.int
Returns the currently set timeout, for how oftenHasValue.ValueChangeEvent
s are triggered when the ValueChangeMode is set toValueChangeMode.LAZY
, orValueChangeMode.TIMEOUT
.boolean
Specify that this control should have input focus when the page loads.boolean
Specifies if the field value gets automatically selected when the field gains focus.boolean
Alias forisRequiredIndicatorVisible()
boolean
Gets whether the user is required to provide a value.void
setAriaLabel
(String ariaLabel) Set the aria-label of the component to the given text.void
setAriaLabelledBy
(String labelledBy) Set the aria-labelledby of the component.void
setAutofocus
(boolean autofocus) Sets the whether the component should automatically receive focus when the page loads.void
setAutoselect
(boolean autoselect) Set totrue
to always have the field value automatically selected when the field gains focus,false
otherwise.void
Set the label of the component to the given text.void
setRequired
(boolean required) Alias forsetRequiredIndicatorVisible(boolean)
.void
setRequiredIndicatorVisible
(boolean required) Sets whether the user is required to provide a value.void
The text usually displayed in a tooltip popup when the mouse is over the field.void
setValueChangeMode
(ValueChangeMode valueChangeMode) Sets new value change mode for the component.void
setValueChangeTimeout
(int valueChangeTimeout) Sets how oftenHasValue.ValueChangeEvent
s are triggered when the ValueChangeMode is set toValueChangeMode.LAZY
, orValueChangeMode.TIMEOUT
.Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEvent
Methods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEquals
Methods 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, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListener
Methods inherited from interface com.vaadin.flow.component.CompositionNotifier
addCompositionEndListener, addCompositionStartListener, addCompositionUpdateListener
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, getTabIndex, setTabIndex
Methods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListener
Methods inherited from interface com.vaadin.flow.component.textfield.HasAutocapitalize
getAutocapitalize, setAutocapitalize
Methods inherited from interface com.vaadin.flow.component.textfield.HasAutocomplete
getAutocomplete, setAutocomplete
Methods inherited from interface com.vaadin.flow.component.textfield.HasAutocorrect
isAutocorrect, setAutocorrect
Methods inherited from interface com.vaadin.flow.component.shared.HasClearButton
isClearButtonVisible, setClearButtonVisible
Methods inherited from interface com.vaadin.flow.component.shared.HasClientValidation
addClientValidatedEventListener
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
Methods inherited from interface com.vaadin.flow.component.HasHelper
getHelperComponent, getHelperText, setHelperComponent, setHelperText
Methods inherited from interface com.vaadin.flow.component.HasPlaceholder
getPlaceholder, setPlaceholder
Methods inherited from interface com.vaadin.flow.component.shared.HasPrefix
getPrefixComponent, setPrefixComponent
Methods 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, setWidthFull
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
Methods inherited from interface com.vaadin.flow.component.shared.HasSuffix
getSuffixComponent, setSuffixComponent
Methods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipText
Methods inherited from interface com.vaadin.flow.component.HasValidation
setManualValidation
Methods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties
getErrorMessage, isInvalid, setErrorMessage, setInvalid
Methods inherited from interface com.vaadin.flow.data.binder.HasValidator
addValidationStatusChangeListener, getDefaultValidator
Methods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, clear, getEmptyValue, getOptionalValue, getValue, isEmpty, setValue
Methods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, setReadOnly
Methods inherited from interface com.vaadin.flow.component.InputNotifier
addInputListener
Methods 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:
getValueChangeMode
in interfaceHasValueChangeMode
- Returns:
- current value change mode of the component, or
null
if the value is not synchronized
-
setValueChangeMode
Description copied from interface:HasValueChangeMode
Sets new value change mode for the component.- Specified by:
setValueChangeMode
in interfaceHasValueChangeMode
- Parameters:
valueChangeMode
- new value change mode, ornull
to disable the value synchronization
-
setValueChangeTimeout
public void setValueChangeTimeout(int valueChangeTimeout) Description copied from interface:HasValueChangeMode
Sets how oftenHasValue.ValueChangeEvent
s are triggered when the ValueChangeMode is set toValueChangeMode.LAZY
, orValueChangeMode.TIMEOUT
.Implementations should use
ValueChangeMode.applyChangeTimeout(ValueChangeMode, int, DomListenerRegistration)
.- Specified by:
setValueChangeTimeout
in interfaceHasValueChangeMode
- Parameters:
valueChangeTimeout
- the timeout in milliseconds of how oftenHasValue.ValueChangeEvent
s are triggered.
-
getValueChangeTimeout
public int getValueChangeTimeout()Description copied from interface:HasValueChangeMode
Returns the currently set timeout, for how oftenHasValue.ValueChangeEvent
s are triggered when the ValueChangeMode is set toValueChangeMode.LAZY
, orValueChangeMode.TIMEOUT
.- Specified by:
getValueChangeTimeout
in interfaceHasValueChangeMode
- Returns:
- the timeout in milliseconds of how often
HasValue.ValueChangeEvent
s 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
-true
component should automatically receive focus
-
isAutofocus
public boolean isAutofocus()Specify that this control should have input focus when the page loads.- Returns:
- the
autofocus
property from the webcomponent
-
getTitle
The text usually displayed in a tooltip popup when the mouse is over the field.- Returns:
- the
title
property 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:
true
if autoselect is active,false
otherwise
-
setAutoselect
public void setAutoselect(boolean autoselect) Set totrue
to always have the field value automatically selected when the field gains focus,false
otherwise.- Parameters:
autoselect
-true
to set auto select on,false
otherwise
-
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:
setRequiredIndicatorVisible
in interfaceHasValue<TComponent extends TextFieldBase<TComponent,
TValue>, TValue> - Specified by:
setRequiredIndicatorVisible
in interfaceHasValueAndElement<TComponent extends TextFieldBase<TComponent,
TValue>, TValue> - Parameters:
required
-true
to make the field required,false
otherwise
-
isRequiredIndicatorVisible
public boolean isRequiredIndicatorVisible()Gets whether the user is required to provide a value.- Specified by:
isRequiredIndicatorVisible
in interfaceHasValue<TComponent extends TextFieldBase<TComponent,
TValue>, TValue> - Specified by:
isRequiredIndicatorVisible
in interfaceHasValueAndElement<TComponent extends TextFieldBase<TComponent,
TValue>, TValue> - Returns:
true
if the field is required,false
otherwise- See Also:
-
setRequired
public void setRequired(boolean required) Alias forsetRequiredIndicatorVisible(boolean)
.- Parameters:
required
-true
to make the field required,false
otherwise
-
isRequired
public boolean isRequired()Alias forisRequiredIndicatorVisible()
- Returns:
true
if the field is required,false
otherwise
-
setLabel
Description copied from interface:HasLabel
Set the label of the component to the given text. -
setAriaLabel
Description copied from interface:HasAriaLabel
Set 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:
setAriaLabel
in interfaceHasAriaLabel
- Parameters:
ariaLabel
- the aria-label text to set ornull
to clear
-
getAriaLabel
Description copied from interface:HasAriaLabel
Gets the aria-label of the component.- Specified by:
getAriaLabel
in interfaceHasAriaLabel
- Returns:
- an optional aria-label of the component if no aria-label has been set
-
setAriaLabelledBy
Description copied from interface:HasAriaLabel
Set 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:
setAriaLabelledBy
in interfaceHasAriaLabel
- Parameters:
labelledBy
- the string with the id of the element that will be used as label ornull
to clear
-
getAriaLabelledBy
Description copied from interface:HasAriaLabel
Gets the aria-labelledby of the component- Specified by:
getAriaLabelledBy
in 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:
-