Class EmailField

  • All Implemented Interfaces:
    com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<EmailField>, com.vaadin.flow.component.CompositionNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<EmailField>, com.vaadin.flow.component.FocusNotifier<EmailField>, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasHelper, com.vaadin.flow.component.HasLabel, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.HasValidation, com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EmailField,​String>,​String>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EmailField,​String>,​String>, com.vaadin.flow.component.InputNotifier, com.vaadin.flow.component.KeyNotifier, HasAllowedCharPattern, HasClearButton, HasThemeVariant<TextFieldVariant>, HasTooltip, HasAutocapitalize, HasAutocomplete, HasAutocorrect, HasPrefixAndSuffix, com.vaadin.flow.data.binder.HasValidator<String>, com.vaadin.flow.data.value.HasValueChangeMode, Serializable

    public class EmailField
    extends GeneratedVaadinEmailField<EmailField,​String>
    implements com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasValidation, com.vaadin.flow.data.value.HasValueChangeMode, HasPrefixAndSuffix, com.vaadin.flow.component.InputNotifier, com.vaadin.flow.component.KeyNotifier, com.vaadin.flow.component.CompositionNotifier, HasAutocomplete, HasAutocapitalize, HasAutocorrect, com.vaadin.flow.component.HasHelper, com.vaadin.flow.component.HasLabel, HasClearButton, HasAllowedCharPattern, HasThemeVariant<TextFieldVariant>, HasTooltip, com.vaadin.flow.data.binder.HasValidator<String>
    Email Field is an extension of Text Field that only accepts email addresses as input. If the given address is invalid, the field is highlighted in red and an error message appears underneath the input. The validity of the email addresses is checked according to the RFC 5322 standard, which includes the format for email addresses. The component also supports supplying additional validation criteria using a regular expression (see setPattern(String)). These extra validation criteria can be used, for example, to require a specific email domain.
    Author:
    Vaadin Ltd.
    See Also:
    Serialized Form
    • Constructor Detail

      • EmailField

        public EmailField()
        Constructs an empty EmailField.
      • EmailField

        public EmailField​(String label)
        Constructs an empty EmailField with the given label.
        Parameters:
        label - the text to set as the label
      • EmailField

        public EmailField​(String label,
                          String placeholder)
        Constructs an empty EmailField with the given label and placeholder text.
        Parameters:
        label - the text to set as the label
        placeholder - the placeholder text to set
      • EmailField

        public EmailField​(com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EmailField,​String>> listener)
        Constructs an empty EmailField with a value change listener.
        Parameters:
        listener - the value change listener
        See Also:
        AbstractField.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)
      • EmailField

        public EmailField​(String label,
                          com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EmailField,​String>> listener)
        Constructs an empty EmailField with a value change listener and a label.
        Parameters:
        label - the text to set as the label
        listener - the value change listener
        See Also:
        setLabel(String), AbstractField.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)
      • EmailField

        public EmailField​(String label,
                          String initialValue,
                          com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EmailField,​String>> listener)
        Constructs a EmailField with a value change listener, a label and an initial value.
        Parameters:
        label - the text to set as the label
        initialValue - the initial value
        listener - the value change listener
        See Also:
        setLabel(String), AbstractField.setValue(Object), AbstractField.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)
    • Method Detail

      • getValueChangeMode

        public com.vaadin.flow.data.value.ValueChangeMode getValueChangeMode()

        The default value is ValueChangeMode.ON_CHANGE.

        Specified by:
        getValueChangeMode in interface com.vaadin.flow.data.value.HasValueChangeMode
      • setValueChangeMode

        public void setValueChangeMode​(com.vaadin.flow.data.value.ValueChangeMode valueChangeMode)
        Specified by:
        setValueChangeMode in interface com.vaadin.flow.data.value.HasValueChangeMode
      • setValueChangeTimeout

        public void setValueChangeTimeout​(int valueChangeTimeout)
        Specified by:
        setValueChangeTimeout in interface com.vaadin.flow.data.value.HasValueChangeMode
      • getValueChangeTimeout

        public int getValueChangeTimeout()
        Specified by:
        getValueChangeTimeout in interface com.vaadin.flow.data.value.HasValueChangeMode
      • getErrorMessage

        public String getErrorMessage()
        Specified by:
        getErrorMessage in interface com.vaadin.flow.component.HasValidation
      • setErrorMessage

        public void setErrorMessage​(String errorMessage)
        Description copied from class: GeneratedVaadinTextField

        Description copied from corresponding location in WebComponent:

        Error to show when the input value is invalid.

        Specified by:
        setErrorMessage in interface com.vaadin.flow.component.HasValidation
        Overrides:
        setErrorMessage in class GeneratedVaadinTextField<EmailField,​String>
        Parameters:
        errorMessage - the String value to set
      • isInvalid

        public boolean isInvalid()
        Specified by:
        isInvalid in interface com.vaadin.flow.component.HasValidation
      • setInvalid

        public void setInvalid​(boolean invalid)
        Description copied from class: GeneratedVaadinTextField

        Description copied from corresponding location in WebComponent:

        This property is set to true when the control value is invalid.

        Specified by:
        setInvalid in interface com.vaadin.flow.component.HasValidation
        Overrides:
        setInvalid in class GeneratedVaadinTextField<EmailField,​String>
        Parameters:
        invalid - the boolean value to set
      • setLabel

        public void setLabel​(String label)
        Description copied from class: GeneratedVaadinTextField

        Description copied from corresponding location in WebComponent:

        String used for the label element.

        Specified by:
        setLabel in interface com.vaadin.flow.component.HasLabel
        Overrides:
        setLabel in class GeneratedVaadinTextField<EmailField,​String>
        Parameters:
        label - the String value to set
      • getLabel

        public String getLabel()
        String used for the label element.
        Specified by:
        getLabel in interface com.vaadin.flow.component.HasLabel
        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
      • 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<EmailField,​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
      • isPreventInvalidInput

        @Deprecated
        public boolean isPreventInvalidInput()
        Deprecated.
        Since 23.2, this API is deprecated.
        When set to true, user is prevented from typing a value that conflicts with the given pattern.
        Returns:
        the preventInvalidInput property from the webcomponent
      • 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<EmailField,​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()
        The text usually displayed in a tooltip popup when the mouse is over the field.
        Returns:
        the title 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<EmailField,​String>
        Parameters:
        autoselect - true to set auto select on, false otherwise
      • getEmptyValue

        public String getEmptyValue()
        Specified by:
        getEmptyValue in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EmailField,​String>,​String>
        Overrides:
        getEmptyValue in class com.vaadin.flow.component.AbstractField<EmailField,​String>
      • setValue

        public void setValue​(String value)
        Sets the value of this email field. If the new value is not equal to getValue(), fires a value change event. Throws NullPointerException, if the value is null.

        Note: Binder will take care of the null conversion when integrates with email field, as long as no new converter is defined.

        Specified by:
        setValue in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EmailField,​String>,​String>
        Overrides:
        setValue in class com.vaadin.flow.component.AbstractField<EmailField,​String>
        Parameters:
        value - the new value, not null
      • getValue

        public String getValue()
        Returns the current value of the email field. By default, the empty email field will return an empty string.
        Specified by:
        getValue in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EmailField,​String>,​String>
        Overrides:
        getValue in class com.vaadin.flow.component.AbstractField<EmailField,​String>
        Returns:
        the current value.
      • setRequiredIndicatorVisible

        public void setRequiredIndicatorVisible​(boolean requiredIndicatorVisible)
        Specified by:
        setRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EmailField,​String>,​String>
        Specified by:
        setRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<EmailField,​String>,​String>
      • getDefaultValidator

        public com.vaadin.flow.data.binder.Validator<String> getDefaultValidator()
        Specified by:
        getDefaultValidator in interface com.vaadin.flow.data.binder.HasValidator<String>
      • validate

        protected void validate()
        Performs server-side validation of the current value. This is needed because it is possible to circumvent the client-side validation constraints using browser development tools.
        Overrides:
        validate in class GeneratedVaadinTextField<EmailField,​String>
      • onAttach

        protected void onAttach​(com.vaadin.flow.component.AttachEvent attachEvent)
        Overrides:
        onAttach in class com.vaadin.flow.component.Component
      • isFeatureFlagEnabled

        protected boolean isFeatureFlagEnabled​(com.vaadin.experimental.Feature feature)
        Returns true if the given feature flag is enabled, false otherwise.

        Exposed with protected visibility to support mocking

        The method requires the VaadinService instance to obtain the available feature flags, otherwise, the feature is considered disabled.

        Parameters:
        feature - the feature flag.
        Returns:
        whether the feature flag is enabled.