com.vaadin.flow.component.textfield.

Class TextField

    • Method Detail

      • 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

      • getErrorMessage

        public String getErrorMessage()

        Description copied from interface: HasValidation

        Gets current error message from the component.

        Specified by:

        getErrorMessage in interface HasValidation

        Returns:

        current error message

      • isInvalid

        public boolean isInvalid()

        Description copied from interface: HasValidation

        Returns true if component input is invalid, false otherwise.

        Specified by:

        isInvalid in interface HasValidation

        Returns:

        whether the component input is valid

      • getLabel

        public String getLabel()

        String used for the label element.

        Returns:

        the label property from the webcomponent

      • getPlaceholder

        public String getPlaceholder()

        A hint to the user of what can be entered in the component.

        Returns:

        the placeholder property from the webcomponent

      • 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.

        Overrides:

        setAutoselect in class GeneratedVaadinTextField<TextField,String>

        Parameters:

        autoselect - true to set auto select on, false otherwise

      • isClearButtonVisible

        public boolean isClearButtonVisible()

        Gets the visibility state of the button which clears the text field.

        Returns:

        true if the button is visible, false otherwise

      • setClearButtonVisible

        public void setClearButtonVisible(boolean clearButtonVisible)

        Set to false to hide the clear button which clears the text field.

        Overrides:

        setClearButtonVisible in class GeneratedVaadinTextField<TextField,String>

        Parameters:

        clearButtonVisible - true to set the button visible, false otherwise

      • setAutofocus

        public void setAutofocus(boolean autofocus)

        Description copied from class: GeneratedVaadinTextField

        Description copied from corresponding location in WebComponent:

        Specify that this control should have input focus when the page loads.

        Overrides:

        setAutofocus in class GeneratedVaadinTextField<TextField,String>

        Parameters:

        autofocus - the boolean value to set

      • isAutofocus

        public boolean isAutofocus()

        Specify that this control should have input focus when the page loads.

        Returns:

        the autofocus property from the webcomponent

      • setMaxLength

        public void setMaxLength(int maxLength)

        Maximum number of characters (in Unicode code points) that the user can enter.

        Parameters:

        maxLength - the maximum length

      • getMaxLength

        public int getMaxLength()

        Maximum number of characters (in Unicode code points) that the user can enter.

        Returns:

        the maxlength property from the webcomponent

      • setMinLength

        public void setMinLength(int minLength)

        Minimum number of characters (in Unicode code points) that the user can enter.

        Parameters:

        minLength - the minimum length

      • getMinLength

        public int getMinLength()

        Minimum number of characters (in Unicode code points) that the user can enter.

        Returns:

        the minlength property from the webcomponent

      • isRequired

        public boolean isRequired()

        Specifies that the user must fill in a value.

        Returns:

        the required property from the webcomponent

      • setRequired

        public void setRequired(boolean required)

        Specifies that the user must fill in a value.

        NOTE: The required indicator will not be visible, if there is no label property set for the textfield.

        Overrides:

        setRequired in class GeneratedVaadinTextField<TextField,String>

        Parameters:

        required - the boolean value to set

      • isPreventInvalidInput

        public boolean isPreventInvalidInput()

        When set to true, user is prevented from typing a value that conflicts with the given pattern.

        Returns:

        the preventInvalidInput property from the webcomponent

      • setPreventInvalidInput

        public void setPreventInvalidInput(boolean preventInvalidInput)

        Description copied from class: GeneratedVaadinTextField

        Description copied from corresponding location in WebComponent:

        When set to true, user is prevented from typing a value that conflicts with the given pattern.

        Overrides:

        setPreventInvalidInput in class GeneratedVaadinTextField<TextField,String>

        Parameters:

        preventInvalidInput - the boolean value to set

      • setPattern

        public void setPattern(String pattern)

        Description copied from class: GeneratedVaadinTextField

        Description copied from corresponding location in WebComponent:

        A regular expression that the value is checked against. The pattern must match the entire value, not just some subset.

        Overrides:

        setPattern in class GeneratedVaadinTextField<TextField,String>

        Parameters:

        pattern - the String value to set

      • getPattern

        public String getPattern()

        A regular expression that the value is checked against. The pattern must match the entire value, not just some subset.

        Returns:

        the pattern property from the webcomponent

      • getTitle

        public String getTitle()

        Message to show to the user when validation fails.

        Returns:

        the title property from the webcomponent

      • setRequiredIndicatorVisible

        public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible)

        Description copied from interface: HasValue

        Sets the required indicator visible or not.

        If set visible, it is visually indicated in the user interface.

        The method is intended to be used with Binder which does server-side validation. In case HTML element has its own (client-side) validation it should be disabled when setRequiredIndicatorVisible(true) is called and re-enabled back on setRequiredIndicatorVisible(false). It's responsibility of each component implementation to follow the contract so that the method call doesn't do anything else than show/hide the "required" indication. Usually components provide their own setRequired method which should be called in case the client-side validation is required.

        Specified by:

        setRequiredIndicatorVisible in interface HasValue<AbstractField.ComponentValueChangeEvent<TextField,String>,String>

        Specified by:

        setRequiredIndicatorVisible in interface HasValueAndElement<AbstractField.ComponentValueChangeEvent<TextField,String>,String>

        Parameters:

        requiredIndicatorVisible - true to make the required indicator visible, false if not