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 class
TValue - 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, HasSize, HasStyle, HasValidation, HasValue<AbstractField.ComponentValueChangeEvent<TComponent,TValue>,TValue>, HasValueAndElement<AbstractField.ComponentValueChangeEvent<TComponent,TValue>,TValue>, InputNotifier, KeyNotifier, HasClearButton, HasClientValidation, HasPrefix, HasSuffix, HasTooltip, HasValidationProperties, 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, HasHelper, HasLabel, HasPrefixAndSuffix, HasSize, HasStyle, HasTooltip, HasValidationProperties, HasValidator<TValue>, HasValueChangeMode, InputNotifier, KeyNotifier
Internal class that provides base functionality for input field components, such as TextField. Not intended to be used publicly.
See Also:
  • Method Details

    • getValueChangeMode

      public ValueChangeMode getValueChangeMode()
      Gets current value change mode of the component.

      The default value is ValueChangeMode.ON_CHANGE.

      Specified by:
      getValueChangeMode in interface HasValueChangeMode
      Returns:
      current value change mode of the component, or null if the value is not synchronized
    • setValueChangeMode

      public void setValueChangeMode(ValueChangeMode valueChangeMode)
      Description copied from interface: HasValueChangeMode
      Sets new value change mode for the component.
      Specified by:
      setValueChangeMode in interface HasValueChangeMode
      Parameters:
      valueChangeMode - new value change mode, or null to disable the value synchronization
    • setValueChangeTimeout

      public void setValueChangeTimeout(int valueChangeTimeout)
      Description copied from interface: HasValueChangeMode
      Sets how often HasValue.ValueChangeEvents are triggered when the ValueChangeMode is set to ValueChangeMode.LAZY, or ValueChangeMode.TIMEOUT.

      Implementations should use ValueChangeMode.applyChangeTimeout(ValueChangeMode, int, DomListenerRegistration).

      Specified by:
      setValueChangeTimeout in interface HasValueChangeMode
      Parameters:
      valueChangeTimeout - the timeout in milliseconds of how often HasValue.ValueChangeEvents are triggered.
    • getValueChangeTimeout

      public int getValueChangeTimeout()
      Description copied from interface: HasValueChangeMode
      Returns the currently set timeout, for how often HasValue.ValueChangeEvents are triggered when the ValueChangeMode is set to ValueChangeMode.LAZY, or ValueChangeMode.TIMEOUT.
      Specified by:
      getValueChangeTimeout in interface HasValueChangeMode
      Returns:
      the timeout in milliseconds of how often HasValue.ValueChangeEvents are triggered.
    • setPlaceholder

      public void setPlaceholder(String placeholder)
      Sets the placeholder text that should be displayed in the input element, when the user has not entered a value
      Parameters:
      placeholder - the placeholder text
    • getPlaceholder

      public String getPlaceholder()
      The placeholder text that should be displayed in the input element, when the user has not entered a value
      Returns:
      the placeholder property from the web component
    • setAutofocus

      public void setAutofocus(boolean autofocus)
      Sets the whether the component should automatically receive focus when the page loads. Defaults to false.
      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

      public String getTitle()
      The text usually displayed in a tooltip popup when the mouse is over the field.
      Returns:
      the title property from the webcomponent
    • setTitle

      public void setTitle(String title)
      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 to true 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
    • setRequired

      public void setRequired(boolean required)
      Specifies that the user must fill in a value.
      Parameters:
      required - the boolean value to set
    • isRequired

      public boolean isRequired()
      Determines whether the field is marked as input required.
      Returns:
      true if the input is required, false otherwise
    • setLabel

      public void setLabel(String label)
      Description copied from interface: HasLabel
      Set the label of the component to the given text.
      Specified by:
      setLabel in interface HasLabel
      Parameters:
      label - the label text to set or null to clear
    • setAriaLabel

      public void setAriaLabel(String ariaLabel)
      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 interface HasAriaLabel
      Parameters:
      ariaLabel - the aria-label text to set or null to clear
    • getAriaLabel

      public Optional<String> getAriaLabel()
      Description copied from interface: HasAriaLabel
      Gets the aria-label of the component.
      Specified by:
      getAriaLabel in interface HasAriaLabel
      Returns:
      an optional aria-label of the component if no aria-label has been set
    • setAriaLabelledBy

      public void setAriaLabelledBy(String labelledBy)
      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 interface HasAriaLabel
      Parameters:
      labelledBy - the string with the id of the element that will be used as label or null to clear
    • getAriaLabelledBy

      public Optional<String> getAriaLabelledBy()
      Description copied from interface: HasAriaLabel
      Gets the aria-labelledby of the component
      Specified by:
      getAriaLabelledBy in interface HasAriaLabel
      Returns:
      an optional aria-labelledby of the component if no aria-labelledby has been set
    • addToPrefix

      protected void addToPrefix(Component... components)
      Adds the given components as children of this component at the slot 'prefix'.
      Parameters:
      components - The components to add.
      See Also:
    • addToInput

      protected void addToInput(Component... components)
      Adds the given components as children of this component at the slot 'input'.
      Parameters:
      components - The components to add.
      See Also:
    • addToSuffix

      protected void addToSuffix(Component... components)
      Adds the given components as children of this component at the slot 'suffix'.
      Parameters:
      components - The components to add.
      See Also: