public class EmailField extends GeneratedVaadinEmailField<EmailField,String> implements HasSize, HasValidation, HasValueChangeMode, HasPrefixAndSuffix, InputNotifier, KeyNotifier, CompositionNotifier, HasAutocomplete, HasAutocapitalize, HasAutocorrect, HasHelper, HasLabel
vaadin-email-field
element.GeneratedVaadinTextField.ChangeEvent<R extends GeneratedVaadinTextField<R,?>>, GeneratedVaadinTextField.InvalidChangeEvent<R extends GeneratedVaadinTextField<R,?>>
AbstractField.ComponentValueChangeEvent<C extends Component,V>
BlurNotifier.BlurEvent<C extends Component>
FocusNotifier.FocusEvent<C extends Component>
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<E extends HasValue.ValueChangeEvent<?>>
DEFAULT_CHANGE_TIMEOUT
AUTOCOMPLETE_ATTRIBUTE
AUTOCAPITALIZE_ATTRIBUTE
AUTOCORRECT_ATTRIBUTE
Constructor and Description |
---|
EmailField()
Constructs an empty
EmailField . |
EmailField(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<EmailField,String>> listener)
Constructs an empty
EmailField with a value change listener. |
EmailField(String label)
Constructs an empty
EmailField with the given label. |
EmailField(String label,
HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<EmailField,String>> listener)
Constructs an empty
EmailField with a value change listener and a
label. |
EmailField(String label,
String placeholder)
Constructs an empty
EmailField with the given label and
placeholder text. |
EmailField(String label,
String initialValue,
HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<EmailField,String>> listener)
Constructs a
EmailField with a value change listener, a label and
an initial value. |
Modifier and Type | Method and Description |
---|---|
String |
getEmptyValue()
Returns the value that represents an empty value.
|
String |
getErrorMessage()
Gets current error message from the component.
|
String |
getLabel()
String used for the label element.
|
int |
getMaxLength()
Maximum number of characters (in Unicode code points) that the user can
enter.
|
int |
getMinLength()
Minimum number of characters (in Unicode code points) that the user can
enter.
|
String |
getPattern()
A regular expression that the value is checked against.
|
String |
getPlaceholder()
A hint to the user of what can be entered in the component.
|
String |
getTitle()
The text usually displayed in a tooltip popup when the mouse is over the
field.
|
String |
getValue()
Returns the current value of the email field.
|
ValueChangeMode |
getValueChangeMode()
Gets current value change mode of the component.
|
int |
getValueChangeTimeout()
Returns the currently set timeout, for how often
HasValue.ValueChangeEvent s are triggered when the ValueChangeMode is set
to ValueChangeMode.LAZY , or ValueChangeMode.TIMEOUT . |
boolean |
isAutofocus()
Specify that this control should have input focus when the page loads.
|
boolean |
isAutoselect()
Specifies if the field value gets automatically selected when the field
gains focus.
|
boolean |
isClearButtonVisible()
Gets the visibility state of the button which clears the email field.
|
boolean |
isInvalid()
Returns
true if component input is invalid, false
otherwise. |
boolean |
isPreventInvalidInput()
When set to
true , user is prevented from typing a value that
conflicts with the given pattern . |
protected void |
onAttach(AttachEvent attachEvent)
Called when the component is attached to a UI.
|
void |
setAutofocus(boolean autofocus)
Description copied from corresponding location in WebComponent:
|
void |
setAutoselect(boolean autoselect)
Set to
true to always have the field value automatically
selected when the field gains focus, false otherwise. |
void |
setClearButtonVisible(boolean clearButtonVisible)
Set to
false to hide the clear button which clears the email
field. |
void |
setErrorMessage(String errorMessage)
Description copied from corresponding location in WebComponent:
|
void |
setInvalid(boolean invalid)
Description copied from corresponding location in WebComponent:
|
void |
setLabel(String label)
Sets the label for this component.
|
void |
setMaxLength(int maxLength)
Maximum number of characters (in Unicode code points) that the user can
enter.
|
void |
setMinLength(int minLength)
Minimum number of characters (in Unicode code points) that the user can
enter.
|
void |
setPattern(String pattern)
Description copied from corresponding location in WebComponent:
|
void |
setPlaceholder(String placeholder)
Description copied from corresponding location in WebComponent:
|
void |
setPreventInvalidInput(boolean preventInvalidInput)
Description copied from corresponding location in WebComponent:
|
void |
setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
Sets the required indicator visible or not.
|
void |
setTitle(String title)
Description copied from corresponding location in WebComponent:
|
void |
setValue(String value)
Sets the value of this email field.
|
void |
setValueChangeMode(ValueChangeMode valueChangeMode)
Sets new value change mode for the component.
|
void |
setValueChangeTimeout(int valueChangeTimeout)
Sets how often
HasValue.ValueChangeEvent s are triggered when the
ValueChangeMode is set to ValueChangeMode.LAZY , or
ValueChangeMode.TIMEOUT . |
protected void |
validate()
Performs server-side validation of the current value.
|
addChangeListener, addInvalidChangeListener, addThemeVariants, addToInput, addToPrefix, addToSuffix, checkValidity, getAutocapitalizeString, getAutocompleteString, getAutocorrectString, getErrorMessageString, getLabelString, getListString, getMaxlengthDouble, getMinlengthDouble, getNameString, getPatternString, getPlaceholderString, getTitleString, isAutofocusBoolean, isAutoselectBoolean, isClearButtonVisibleBoolean, isDisabledBoolean, isInvalidBoolean, isPreventInvalidInputBoolean, isReadonlyBoolean, isRequiredBoolean, remove, removeAll, removeThemeVariants, setAutocapitalize, setAutocomplete, setAutocorrect, setDisabled, setList, setMaxlength, setMinlength, setName, setReadonly, setRequired
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEvent
addValueChangeListener, isEmpty, setModelValue, valueEquals
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCssSize, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
getPrefixComponent, getSuffixComponent, setPrefixComponent, setSuffixComponent
addInputListener
addKeyDownListener, addKeyDownListener, addKeyPressListener, addKeyPressListener, addKeyUpListener, addKeyUpListener
addCompositionEndListener, addCompositionStartListener, addCompositionUpdateListener
getAutocomplete, setAutocomplete
getAutocapitalize, setAutocapitalize
isAutocorrect, setAutocorrect
getHelperComponent, getHelperText, setHelperComponent, setHelperText
getElement
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
addFocusShortcut, blur, focus, getTabIndex, setTabIndex
addBlurListener
addFocusListener
isEnabled, setEnabled
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
isReadOnly, isRequiredIndicatorVisible, setReadOnly
clear, getOptionalValue
addAttachListener
addDetachListener
public EmailField()
EmailField
.public EmailField(String label)
EmailField
with the given label.label
- the text to set as the labelpublic EmailField(String label, String placeholder)
EmailField
with the given label and
placeholder text.label
- the text to set as the labelplaceholder
- the placeholder text to setpublic EmailField(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<EmailField,String>> listener)
EmailField
with a value change listener.listener
- the value change listenerAbstractField.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)
public EmailField(String label, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<EmailField,String>> listener)
EmailField
with a value change listener and a
label.label
- the text to set as the labellistener
- the value change listenersetLabel(String)
,
AbstractField.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)
public EmailField(String label, String initialValue, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<EmailField,String>> listener)
EmailField
with a value change listener, a label and
an initial value.label
- the text to set as the labelinitialValue
- the initial valuelistener
- the value change listenersetLabel(String)
,
AbstractField.setValue(Object)
,
AbstractField.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)
public ValueChangeMode getValueChangeMode()
The default value is ValueChangeMode.ON_CHANGE
.
getValueChangeMode
in interface HasValueChangeMode
null
if
the value is not synchronizedpublic void setValueChangeMode(ValueChangeMode valueChangeMode)
HasValueChangeMode
setValueChangeMode
in interface HasValueChangeMode
valueChangeMode
- new value change mode, or null
to disable the value
synchronizationpublic void setValueChangeTimeout(int valueChangeTimeout)
HasValueChangeMode
HasValue.ValueChangeEvent
s are triggered when the
ValueChangeMode is set to ValueChangeMode.LAZY
, or
ValueChangeMode.TIMEOUT
.
Implementations should use
ValueChangeMode.applyChangeTimeout(ValueChangeMode, int, DomListenerRegistration)
.
setValueChangeTimeout
in interface HasValueChangeMode
valueChangeTimeout
- the timeout in milliseconds of how often
HasValue.ValueChangeEvent
s are triggered.public int getValueChangeTimeout()
HasValueChangeMode
HasValue.ValueChangeEvent
s are triggered when the ValueChangeMode is set
to ValueChangeMode.LAZY
, or ValueChangeMode.TIMEOUT
.getValueChangeTimeout
in interface HasValueChangeMode
HasValue.ValueChangeEvent
s are triggered.public String getErrorMessage()
HasValidation
getErrorMessage
in interface HasValidation
public void setErrorMessage(String errorMessage)
GeneratedVaadinTextField
Description copied from corresponding location in WebComponent:
Error to show when the input value is invalid.
setErrorMessage
in interface HasValidation
setErrorMessage
in class GeneratedVaadinTextField<EmailField,String>
errorMessage
- the String value to setpublic boolean isInvalid()
HasValidation
true
if component input is invalid, false
otherwise.isInvalid
in interface HasValidation
public void setInvalid(boolean invalid)
GeneratedVaadinTextField
Description copied from corresponding location in WebComponent:
This property is set to true when the control value is invalid.
setInvalid
in interface HasValidation
setInvalid
in class GeneratedVaadinTextField<EmailField,String>
invalid
- the boolean value to setpublic void setLabel(String label)
setLabel
in interface HasLabel
setLabel
in class GeneratedVaadinTextField<EmailField,String>
label
- value for the label
property in the webcomponentpublic String getLabel()
public void setPlaceholder(String placeholder)
GeneratedVaadinTextField
Description copied from corresponding location in WebComponent:
A hint to the user of what can be entered in the control.
setPlaceholder
in class GeneratedVaadinTextField<EmailField,String>
placeholder
- the String value to setpublic String getPlaceholder()
placeholder
property from the webcomponentpublic void setAutofocus(boolean autofocus)
GeneratedVaadinTextField
Description copied from corresponding location in WebComponent:
Specify that this control should have input focus when the page loads.
setAutofocus
in class GeneratedVaadinTextField<EmailField,String>
autofocus
- the boolean value to setpublic boolean isAutofocus()
autofocus
property from the webcomponentpublic void setMaxLength(int maxLength)
maxLength
- the maximum lengthpublic int getMaxLength()
maxlength
property from the webcomponentpublic void setMinLength(int minLength)
minLength
- the minimum lengthpublic int getMinLength()
minlength
property from the webcomponentpublic boolean isPreventInvalidInput()
true
, user is prevented from typing a value that
conflicts with the given pattern
.preventInvalidInput
property from the webcomponentpublic void setPreventInvalidInput(boolean preventInvalidInput)
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
, maxlength
or minlength
properties.
setPreventInvalidInput
in class GeneratedVaadinTextField<EmailField,String>
preventInvalidInput
- the boolean value to setpublic void setPattern(String pattern)
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.
setPattern
in class GeneratedVaadinTextField<EmailField,String>
pattern
- the String value to setpublic String getPattern()
pattern
property from the webcomponentpublic String getTitle()
title
property from the webcomponentpublic void setTitle(String title)
GeneratedVaadinTextField
Description copied from corresponding location in WebComponent:
The text usually displayed in a tooltip popup when the mouse is over the field.
setTitle
in class GeneratedVaadinTextField<EmailField,String>
title
- the String value to setpublic boolean isAutoselect()
true
if autoselect is active, false
otherwisepublic void setAutoselect(boolean autoselect)
true
to always have the field value automatically
selected when the field gains focus, false
otherwise.setAutoselect
in class GeneratedVaadinTextField<EmailField,String>
autoselect
- true
to set auto select on, false
otherwisepublic boolean isClearButtonVisible()
true
if the button is visible, false
otherwisepublic void setClearButtonVisible(boolean clearButtonVisible)
false
to hide the clear button which clears the email
field.setClearButtonVisible
in class GeneratedVaadinTextField<EmailField,String>
clearButtonVisible
- true
to set the button visible,
false
otherwisepublic String getEmptyValue()
HasValue
By default HasValue
is expected to support null
as empty
values. Specific implementations might not support this.
getEmptyValue
in interface HasValue<AbstractField.ComponentValueChangeEvent<EmailField,String>,String>
getEmptyValue
in class AbstractField<EmailField,String>
public void setValue(String value)
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.
setValue
in interface HasValue<AbstractField.ComponentValueChangeEvent<EmailField,String>,String>
setValue
in class AbstractField<EmailField,String>
value
- the new value, not null
public String getValue()
getValue
in interface HasValue<AbstractField.ComponentValueChangeEvent<EmailField,String>,String>
getValue
in class AbstractField<EmailField,String>
public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
HasValue
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.
setRequiredIndicatorVisible
in interface HasValue<AbstractField.ComponentValueChangeEvent<EmailField,String>,String>
setRequiredIndicatorVisible
in interface HasValueAndElement<AbstractField.ComponentValueChangeEvent<EmailField,String>,String>
requiredIndicatorVisible
- true
to make the required indicator visible,
false
if notprotected void validate()
validate
in class GeneratedVaadinTextField<EmailField,String>
protected void onAttach(AttachEvent attachEvent)
Component
The default implementation does nothing.
This method is invoked before the AttachEvent
is fired for the
component.
Copyright © 2023. All rights reserved.