Class PasswordField
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<PasswordField,String>
com.vaadin.flow.component.textfield.PasswordField
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.BlurNotifier<PasswordField>,com.vaadin.flow.component.CompositionNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<PasswordField>,com.vaadin.flow.component.FocusNotifier<PasswordField>,com.vaadin.flow.component.HasAriaLabel,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasHelper,com.vaadin.flow.component.HasLabel,com.vaadin.flow.component.HasPlaceholder,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<PasswordField,,String>, String> com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<PasswordField,,String>, String> com.vaadin.flow.component.InputNotifier,com.vaadin.flow.component.KeyNotifier,HasAllowedCharPattern,HasClearButton,HasClientValidation,HasPrefix,HasSuffix,HasThemeVariant<TextFieldVariant>,HasTooltip,HasValidationProperties,InputField<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<PasswordField,,String>, String> HasAutocapitalize,HasAutocomplete,HasAutocorrect,HasPrefixAndSuffix,com.vaadin.flow.data.binder.HasValidator<String>,com.vaadin.flow.data.value.HasValueChangeMode,Serializable
@Tag("vaadin-password-field")
@NpmPackage(value="@vaadin/polymer-legacy-adapter",version="24.4.5") @NpmPackage(value="@vaadin/password-field",version="24.4.5")
@JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@vaadin/password-field/src/vaadin-password-field.js")
public class PasswordField
extends TextFieldBase<PasswordField,String>
implements HasAllowedCharPattern, HasThemeVariant<TextFieldVariant>
Password Field is an input field for entering passwords. The input is masked
by default. On mobile devices the last typed letter is shown for a brief
moment. The masking can be toggled using an optional reveal button.
- Author:
- Vaadin Ltd.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V extends Object> Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.shared.HasClientValidation
HasClientValidation.ClientValidatedEventNested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
com.vaadin.flow.component.HasValue.ValueChangeEvent<V extends Object>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>> -
Field Summary
Fields inherited from interface com.vaadin.flow.component.textfield.HasAutocapitalize
AUTOCAPITALIZE_ATTRIBUTEFields inherited from interface com.vaadin.flow.component.textfield.HasAutocomplete
AUTOCOMPLETE_ATTRIBUTEFields inherited from interface com.vaadin.flow.component.textfield.HasAutocorrect
AUTOCORRECT_ATTRIBUTEFields inherited from interface com.vaadin.flow.data.value.HasValueChangeMode
DEFAULT_CHANGE_TIMEOUT -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an emptyPasswordField.PasswordField(com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<PasswordField, String>> listener) Constructs an emptyPasswordFieldwith a value change listener.PasswordField(String label) Constructs an emptyPasswordFieldwith the given label.PasswordField(String label, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<PasswordField, String>> listener) Constructs an emptyPasswordFieldwith a value change listener and a label.PasswordField(String label, String placeholder) Constructs an emptyPasswordFieldwith the given label and placeholder text.PasswordField(String label, String initialValue, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<PasswordField, String>> listener) Constructs aPasswordFieldwith a value change listener, a label and an initial value. -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.data.binder.Validator<String>intMaximum number of characters (in Unicode code points) that the user can enter.intMinimum number of characters (in Unicode code points) that the user can enter.A regular expression that the value is checked against.getValue()Returns the current value of the password field.booleanSet tofalseto hide the eye icon which toggles the password visibility.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) voidsetManualValidation(boolean enabled) voidsetMaxLength(int maxLength) Maximum number of characters (in Unicode code points) that the user can enter.voidsetMinLength(int minLength) Minimum number of characters (in Unicode code points) that the user can enter.voidsetPattern(String pattern) Sets a regular expression for the value to pass on the client-side.voidsetRequired(boolean required) Specifies that the user must fill in a value.voidsetRequiredIndicatorVisible(boolean requiredIndicatorVisible) voidsetRevealButtonVisible(boolean revealButtonVisible) Set tofalseto hide the eye icon which toggles the password visibility.voidSets the value of this password field.protected voidvalidate()Performs server-side validation of the current value.Methods inherited from class com.vaadin.flow.component.textfield.TextFieldBase
addToInput, addToPrefix, addToSuffix, getAriaLabel, getAriaLabelledBy, getTitle, getValueChangeMode, getValueChangeTimeout, isAutofocus, isAutoselect, isRequired, setAriaLabel, setAriaLabelledBy, setAutofocus, setAutoselect, setLabel, setTitle, setValueChangeMode, setValueChangeTimeoutMethods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEventMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, isEmpty, setModelValue, valueEqualsMethods 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, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.CompositionNotifier
addCompositionEndListener, addCompositionStartListener, addCompositionUpdateListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.shared.HasAllowedCharPattern
getAllowedCharPattern, setAllowedCharPatternMethods inherited from interface com.vaadin.flow.component.textfield.HasAutocapitalize
getAutocapitalize, setAutocapitalizeMethods inherited from interface com.vaadin.flow.component.textfield.HasAutocomplete
getAutocomplete, setAutocompleteMethods inherited from interface com.vaadin.flow.component.textfield.HasAutocorrect
isAutocorrect, setAutocorrectMethods inherited from interface com.vaadin.flow.component.shared.HasClearButton
isClearButtonVisible, setClearButtonVisibleMethods inherited from interface com.vaadin.flow.component.shared.HasClientValidation
addClientValidatedEventListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasHelper
getHelperComponent, getHelperText, setHelperComponent, setHelperTextMethods inherited from interface com.vaadin.flow.component.HasLabel
getLabelMethods inherited from interface com.vaadin.flow.component.HasPlaceholder
getPlaceholder, setPlaceholderMethods inherited from interface com.vaadin.flow.component.shared.HasPrefix
getPrefixComponent, setPrefixComponentMethods 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, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.shared.HasSuffix
getSuffixComponent, setSuffixComponentMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, removeThemeVariantsMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipTextMethods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties
getErrorMessage, isInvalid, setErrorMessage, setInvalidMethods inherited from interface com.vaadin.flow.data.binder.HasValidator
addValidationStatusChangeListenerMethods inherited from interface com.vaadin.flow.component.HasValue
addValueChangeListener, clear, getOptionalValue, isEmptyMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, isRequiredIndicatorVisible, setReadOnlyMethods inherited from interface com.vaadin.flow.component.InputNotifier
addInputListenerMethods inherited from interface com.vaadin.flow.component.KeyNotifier
addKeyDownListener, addKeyDownListener, addKeyPressListener, addKeyPressListener, addKeyUpListener, addKeyUpListener
-
Constructor Details
-
PasswordField
public PasswordField()Constructs an emptyPasswordField. -
PasswordField
Constructs an emptyPasswordFieldwith the given label.- Parameters:
label- the text to set as the label
-
PasswordField
Constructs an emptyPasswordFieldwith the given label and placeholder text.- Parameters:
label- the text to set as the labelplaceholder- the placeholder text to set
-
PasswordField
public PasswordField(com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<PasswordField, String>> listener) Constructs an emptyPasswordFieldwith a value change listener.- Parameters:
listener- the value change listener- See Also:
-
AbstractField.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)
-
PasswordField
public PasswordField(String label, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<PasswordField, String>> listener) Constructs an emptyPasswordFieldwith a value change listener and a label.- Parameters:
label- the text to set as the labellistener- the value change listener- See Also:
-
TextFieldBase.setLabel(String)AbstractField.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)
-
PasswordField
public PasswordField(String label, String initialValue, com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<PasswordField, String>> listener) Constructs aPasswordFieldwith a value change listener, a label and an initial value.- Parameters:
label- the text to set as the labelinitialValue- the initial valuelistener- the value change listener- See Also:
-
TextFieldBase.setLabel(String)AbstractField.setValue(Object)AbstractField.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)
-
-
Method Details
-
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
maxlengthproperty 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
minlengthproperty from the webcomponent
-
setRequired
public void setRequired(boolean required) Description copied from class:TextFieldBaseSpecifies that the user must fill in a value.- Overrides:
setRequiredin classTextFieldBase<PasswordField,String> - Parameters:
required- the boolean value to set
-
setPattern
Sets a regular expression for the value to pass on the client-side. The pattern must be a valid JavaScript Regular Expression that matches the entire value, not just some subset.- Parameters:
pattern- the new String pattern- See Also:
-
getPattern
A regular expression that the value is checked against. The pattern must match the entire value, not just some subset.- Returns:
- the
patternproperty from the webcomponent
-
isRevealButtonVisible
public boolean isRevealButtonVisible()Set tofalseto hide the eye icon which toggles the password visibility.- Returns:
trueif the button is visible,falseotherwise
-
setRevealButtonVisible
public void setRevealButtonVisible(boolean revealButtonVisible) Set tofalseto hide the eye icon which toggles the password visibility.- Parameters:
revealButtonVisible-trueto set the button visible,falseotherwise
-
getEmptyValue
- Specified by:
getEmptyValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<PasswordField,String>, String> - Overrides:
getEmptyValuein classcom.vaadin.flow.component.AbstractField<PasswordField,String>
-
setValue
Sets the value of this password field. If the new value is not equal togetValue(), fires a value change event. ThrowsNullPointerException, if the value is null.Note:
Binderwill take care of thenullconversion when integrates with password field, as long as no new converter is defined.- Specified by:
setValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<PasswordField,String>, String> - Overrides:
setValuein classcom.vaadin.flow.component.AbstractField<PasswordField,String> - Parameters:
value- the new value, notnull
-
getValue
Returns the current value of the password field. By default, the empty password field will return an empty string.- Specified by:
getValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<PasswordField,String>, String> - Overrides:
getValuein classcom.vaadin.flow.component.AbstractField<PasswordField,String> - Returns:
- the current value.
-
setRequiredIndicatorVisible
public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible) - Specified by:
setRequiredIndicatorVisiblein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<PasswordField,String>, String> - Specified by:
setRequiredIndicatorVisiblein interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<PasswordField,String>, String>
-
getDefaultValidator
- Specified by:
getDefaultValidatorin interfacecom.vaadin.flow.data.binder.HasValidator<String>
-
setManualValidation
public void setManualValidation(boolean enabled) - Specified by:
setManualValidationin interfacecom.vaadin.flow.component.HasValidation
-
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. -
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-