Class AbstractNumberField<C extends AbstractNumberField<C,T>,T extends Number>
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.flow.component.AbstractField<C,T>
-
- com.vaadin.flow.component.AbstractSinglePropertyField<R,T>
-
- com.vaadin.flow.component.textfield.GeneratedVaadinTextField<R,T>
-
- com.vaadin.flow.component.textfield.GeneratedVaadinNumberField<C,T>
-
- com.vaadin.flow.component.textfield.AbstractNumberField<C,T>
-
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.BlurNotifier<C>,com.vaadin.flow.component.CompositionNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<C>,com.vaadin.flow.component.FocusNotifier<C>,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<C,T>,T>,com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C,T>,T>,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<T>,com.vaadin.flow.data.value.HasValueChangeMode,Serializable
- Direct Known Subclasses:
IntegerField,NumberField
public abstract class AbstractNumberField<C extends AbstractNumberField<C,T>,T extends Number> extends GeneratedVaadinNumberField<C,T> 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<T>
Abstract base class for components based onvaadin-number-fieldelement and its subclasses.- Author:
- Vaadin Ltd.
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.vaadin.flow.component.textfield.GeneratedVaadinTextField
GeneratedVaadinTextField.ChangeEvent<R extends GeneratedVaadinTextField<R,?>>, GeneratedVaadinTextField.InvalidChangeEvent<R extends GeneratedVaadinTextField<R,?>>
-
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.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_ATTRIBUTE
-
Fields inherited from interface com.vaadin.flow.component.textfield.HasAutocomplete
AUTOCOMPLETE_ATTRIBUTE
-
Fields inherited from interface com.vaadin.flow.component.textfield.HasAutocorrect
AUTOCORRECT_ATTRIBUTE
-
-
Constructor Summary
Constructors Constructor Description AbstractNumberField(com.vaadin.flow.function.SerializableFunction<String,T> parser, com.vaadin.flow.function.SerializableFunction<T,String> formatter, double absoluteMin, double absoluteMax)Sets up the common logic for number fields.AbstractNumberField(com.vaadin.flow.function.SerializableFunction<String,T> parser, com.vaadin.flow.function.SerializableFunction<T,String> formatter, double absoluteMin, double absoluteMax, boolean isInitialValueOptional)Sets up the common logic for number fields.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddThemeVariants(TextFieldVariant... variants)com.vaadin.flow.data.binder.Validator<T>getDefaultValidator()TgetEmptyValue()Returns the value that represents an empty value.StringgetErrorMessage()StringgetLabel()String used for the label element.protected doublegetMaxDouble()Description copied from corresponding location in WebComponent:protected doublegetMinDouble()Description copied from corresponding location in WebComponent:StringgetPlaceholder()A hint to the user of what can be entered in the component.protected doublegetStepDouble()Description copied from corresponding location in WebComponent:StringgetTitle()The text usually displayed in a tooltip popup when the mouse is over the field.TgetValue()Returns the current value of the number field.com.vaadin.flow.data.value.ValueChangeModegetValueChangeMode()intgetValueChangeTimeout()booleanhasControls()Deprecated.since 23.3.booleanisAutofocus()Specify that this control should have input focus when the page loads.booleanisAutoselect()Specifies if the field value gets automatically selected when the field gains focus.protected booleanisFeatureFlagEnabled(com.vaadin.experimental.Feature feature)Returns true if the given feature flag is enabled, false otherwise.booleanisInvalid()booleanisStepButtonsVisible()Gets whether the buttons for increasing/decreasing the value are visible.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent)voidremoveThemeVariants(TextFieldVariant... variants)voidsetAutofocus(boolean autofocus)Description copied from corresponding location in WebComponent:voidsetAutoselect(boolean autoselect)Set totrueto always have the field value automatically selected when the field gains focus,falseotherwise.voidsetErrorMessage(String errorMessage)Description copied from corresponding location in WebComponent:voidsetHasControls(boolean hasControls)Deprecated.since 23.3.voidsetInvalid(boolean invalid)Description copied from corresponding location in WebComponent:voidsetLabel(String label)Description copied from corresponding location in WebComponent:protected voidsetMax(double max)Description copied from corresponding location in WebComponent:protected voidsetMin(double min)Description copied from corresponding location in WebComponent:voidsetPlaceholder(String placeholder)Description copied from corresponding location in WebComponent:voidsetRequiredIndicatorVisible(boolean requiredIndicatorVisible)protected voidsetStep(double step)Description copied from corresponding location in WebComponent:voidsetStepButtonsVisible(boolean stepButtonsVisible)Sets the visibility of the buttons for increasing/decreasing the value accordingly to the default or specified step.voidsetTitle(String title)Description copied from corresponding location in WebComponent:voidsetValue(T value)Sets the value of this number field.voidsetValueChangeMode(com.vaadin.flow.data.value.ValueChangeMode valueChangeMode)voidsetValueChangeTimeout(int valueChangeTimeout)protected voidvalidate()Performs server-side validation of the current value.-
Methods inherited from class com.vaadin.flow.component.textfield.GeneratedVaadinNumberField
checkValidity, hasControlsBoolean
-
Methods inherited from class com.vaadin.flow.component.textfield.GeneratedVaadinTextField
addChangeListener, addInvalidChangeListener, addToInput, addToPrefix, addToSuffix, getAutocapitalizeString, getAutocompleteString, getAutocorrectString, getErrorMessageString, getLabelString, getListString, getMaxlengthDouble, getMinlengthDouble, getNameString, getPatternString, getPlaceholderString, getTitleString, isAutofocusBoolean, isAutoselectBoolean, isDisabledBoolean, isInvalidBoolean, isPreventInvalidInputBoolean, isReadonlyBoolean, isRequiredBoolean, remove, removeAll, setAutocapitalize, setAutocomplete, setAutocorrect, setDisabled, setList, setMaxlength, setMinlength, setName, setPattern, setPreventInvalidInput, setReadonly, setRequired
-
Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEvent
-
Methods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, isEmpty, setModelValue, valueEquals
-
Methods 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, scrollIntoView, set, setElement, setId, setVisible
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.component.CompositionNotifier
addCompositionEndListener, addCompositionStartListener, addCompositionUpdateListener
-
Methods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, getTabIndex, setTabIndex
-
Methods inherited from interface com.vaadin.flow.component.shared.HasAllowedCharPattern
getAllowedCharPattern, setAllowedCharPattern
-
Methods inherited from interface com.vaadin.flow.component.textfield.HasAutocapitalize
getAutocapitalize, setAutocapitalize
-
Methods inherited from interface com.vaadin.flow.component.textfield.HasAutocomplete
getAutocomplete, setAutocomplete
-
Methods inherited from interface com.vaadin.flow.component.textfield.HasAutocorrect
isAutocorrect, setAutocorrect
-
Methods inherited from interface com.vaadin.flow.component.shared.HasClearButton
isClearButtonVisible, setClearButtonVisible
-
Methods inherited from interface com.vaadin.flow.component.HasHelper
getHelperComponent, getHelperText, setHelperComponent, setHelperText
-
Methods inherited from interface com.vaadin.flow.component.textfield.HasPrefixAndSuffix
getPrefixComponent, getSuffixComponent, setPrefixComponent, setSuffixComponent
-
Methods 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, setWidthFull
-
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Methods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
-
Methods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipText
-
Methods inherited from interface com.vaadin.flow.data.binder.HasValidator
addValidationStatusChangeListener
-
-
-
-
Constructor Detail
-
AbstractNumberField
public AbstractNumberField(com.vaadin.flow.function.SerializableFunction<String,T> parser, com.vaadin.flow.function.SerializableFunction<T,String> formatter, double absoluteMin, double absoluteMax, boolean isInitialValueOptional)
Sets up the common logic for number fields.If
isInitialValueOptionalistruethen the initial value is used only if element has no"value"property value, otherwise element"value"property is ignored and the initial value is set.- Parameters:
parser- function to parse the client-side value string into server-side valueformatter- function to format the server-side value into client-side value stringabsoluteMin- the smallest possible value of the number type of the field, will be used as the default min value at server-sideabsoluteMax- the largest possible value of the number type of the field, will be used as the default max value at server-sideisInitialValueOptional- ifisInitialValueOptionalistruethen the initial value is used only if element has no"value"property value, otherwise element"value"property is ignored and the initial value is set
-
AbstractNumberField
public AbstractNumberField(com.vaadin.flow.function.SerializableFunction<String,T> parser, com.vaadin.flow.function.SerializableFunction<T,String> formatter, double absoluteMin, double absoluteMax)
Sets up the common logic for number fields.- Parameters:
parser- function to parse the client-side value string into server-side valueformatter- function to format the server-side value into client-side value stringabsoluteMin- the smallest possible value of the number type of the field, will be used as the default min value at server-sideabsoluteMax- the largest possible value of the number type of the field, will be used as the default max value at server-side
-
-
Method Detail
-
getValueChangeMode
public com.vaadin.flow.data.value.ValueChangeMode getValueChangeMode()
The default value is
ValueChangeMode.ON_CHANGE.- Specified by:
getValueChangeModein interfacecom.vaadin.flow.data.value.HasValueChangeMode
-
setValueChangeMode
public void setValueChangeMode(com.vaadin.flow.data.value.ValueChangeMode valueChangeMode)
- Specified by:
setValueChangeModein interfacecom.vaadin.flow.data.value.HasValueChangeMode
-
setValueChangeTimeout
public void setValueChangeTimeout(int valueChangeTimeout)
- Specified by:
setValueChangeTimeoutin interfacecom.vaadin.flow.data.value.HasValueChangeMode
-
getValueChangeTimeout
public int getValueChangeTimeout()
- Specified by:
getValueChangeTimeoutin interfacecom.vaadin.flow.data.value.HasValueChangeMode
-
getErrorMessage
public String getErrorMessage()
- Specified by:
getErrorMessagein interfacecom.vaadin.flow.component.HasValidation
-
setErrorMessage
public void setErrorMessage(String errorMessage)
Description copied from class:GeneratedVaadinTextFieldDescription copied from corresponding location in WebComponent:
Error to show when the input value is invalid.
- Specified by:
setErrorMessagein interfacecom.vaadin.flow.component.HasValidation- Overrides:
setErrorMessagein classGeneratedVaadinTextField<C extends AbstractNumberField<C,T>,T extends Number>- Parameters:
errorMessage- the String value to set
-
setLabel
public void setLabel(String label)
Description copied from class:GeneratedVaadinTextFieldDescription copied from corresponding location in WebComponent:
String used for the label element.
- Specified by:
setLabelin interfacecom.vaadin.flow.component.HasLabel- Overrides:
setLabelin classGeneratedVaadinTextField<C extends AbstractNumberField<C,T>,T extends Number>- Parameters:
label- the String value to set
-
getLabel
public String getLabel()
String used for the label element.- Specified by:
getLabelin interfacecom.vaadin.flow.component.HasLabel- Returns:
- the
labelproperty from the webcomponent
-
setPlaceholder
public void setPlaceholder(String placeholder)
Description copied from class:GeneratedVaadinTextFieldDescription copied from corresponding location in WebComponent:
A hint to the user of what can be entered in the control.
- Overrides:
setPlaceholderin classGeneratedVaadinTextField<C extends AbstractNumberField<C,T>,T extends Number>- Parameters:
placeholder- the String value to set
-
setHasControls
@Deprecated public void setHasControls(boolean hasControls)
Deprecated.since 23.3. UsesetStepButtonsVisible(boolean)instead.Sets the visibility of the control buttons for increasing/decreasing the value accordingly to the default or specified step.- Overrides:
setHasControlsin classGeneratedVaadinNumberField<C extends AbstractNumberField<C,T>,T extends Number>- Parameters:
hasControls-trueif control buttons should be visible;falseif those should be hidden- See Also:
setStep(double)
-
hasControls
@Deprecated public boolean hasControls()
Deprecated.since 23.3. UseisStepButtonsVisible()instead.Gets whether the control buttons for increasing/decreasing the value are visible.- Returns:
trueif buttons are visible,falseotherwise- See Also:
setStep(double)
-
setStepButtonsVisible
public void setStepButtonsVisible(boolean stepButtonsVisible)
Sets the visibility of the buttons for increasing/decreasing the value accordingly to the default or specified step.- Parameters:
stepButtonsVisible-trueif control buttons should be visible;falseif those should be hidden- See Also:
setStep(double)
-
isStepButtonsVisible
public boolean isStepButtonsVisible()
Gets whether the buttons for increasing/decreasing the value are visible.- Returns:
trueif buttons are visible,falseotherwise- See Also:
setStep(double)
-
getPlaceholder
public String getPlaceholder()
A hint to the user of what can be entered in the component.- Returns:
- the
placeholderproperty from the webcomponent
-
setAutofocus
public void setAutofocus(boolean autofocus)
Description copied from class:GeneratedVaadinTextFieldDescription copied from corresponding location in WebComponent:
Specify that this control should have input focus when the page loads.
- Overrides:
setAutofocusin classGeneratedVaadinTextField<C extends AbstractNumberField<C,T>,T extends Number>- 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
autofocusproperty from the webcomponent
-
getTitle
public String getTitle()
The text usually displayed in a tooltip popup when the mouse is over the field.- Returns:
- the
titleproperty from the webcomponent
-
setTitle
public void setTitle(String title)
Description copied from class:GeneratedVaadinTextFieldDescription copied from corresponding location in WebComponent:
The text usually displayed in a tooltip popup when the mouse is over the field.
- Overrides:
setTitlein classGeneratedVaadinTextField<C extends AbstractNumberField<C,T>,T extends Number>- 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:
trueif autoselect is active,falseotherwise
-
setAutoselect
public void setAutoselect(boolean autoselect)
Set totrueto always have the field value automatically selected when the field gains focus,falseotherwise.- Overrides:
setAutoselectin classGeneratedVaadinTextField<C extends AbstractNumberField<C,T>,T extends Number>- Parameters:
autoselect-trueto set auto select on,falseotherwise
-
getEmptyValue
public T getEmptyValue()
Returns the value that represents an empty value.
-
setValue
public void setValue(T value)
Sets the value of this number field. If the new value is not equal togetValue(), fires a value change event.
-
getValue
public T getValue()
Returns the current value of the number field. By default, the empty number field will returnnull.
-
setMin
protected void setMin(double min)
Description copied from class:GeneratedVaadinNumberFieldDescription copied from corresponding location in WebComponent:
The minimum value of the field.
- Overrides:
setMinin classGeneratedVaadinNumberField<C extends AbstractNumberField<C,T>,T extends Number>- Parameters:
min- the double value to set
-
getMinDouble
protected double getMinDouble()
Description copied from class:GeneratedVaadinNumberFieldDescription copied from corresponding location in WebComponent:
The minimum value of the field.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
- Overrides:
getMinDoublein classGeneratedVaadinNumberField<C extends AbstractNumberField<C,T>,T extends Number>- Returns:
- the
minproperty from the webcomponent
-
setMax
protected void setMax(double max)
Description copied from class:GeneratedVaadinNumberFieldDescription copied from corresponding location in WebComponent:
The maximum value of the field.
- Overrides:
setMaxin classGeneratedVaadinNumberField<C extends AbstractNumberField<C,T>,T extends Number>- Parameters:
max- the double value to set
-
getMaxDouble
protected double getMaxDouble()
Description copied from class:GeneratedVaadinNumberFieldDescription copied from corresponding location in WebComponent:
The maximum value of the field.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
- Overrides:
getMaxDoublein classGeneratedVaadinNumberField<C extends AbstractNumberField<C,T>,T extends Number>- Returns:
- the
maxproperty from the webcomponent
-
setStep
protected void setStep(double step)
Description copied from class:GeneratedVaadinNumberFieldDescription copied from corresponding location in WebComponent:
Specifies the allowed number intervals of the field.
- Overrides:
setStepin classGeneratedVaadinNumberField<C extends AbstractNumberField<C,T>,T extends Number>- Parameters:
step- the double value to set
-
getStepDouble
protected double getStepDouble()
Description copied from class:GeneratedVaadinNumberFieldDescription copied from corresponding location in WebComponent:
Specifies the allowed number intervals of the field.
This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.
- Overrides:
getStepDoublein classGeneratedVaadinNumberField<C extends AbstractNumberField<C,T>,T extends Number>- Returns:
- the
stepproperty from the webcomponent
-
setInvalid
public void setInvalid(boolean invalid)
Description copied from class:GeneratedVaadinTextFieldDescription copied from corresponding location in WebComponent:
This property is set to true when the control value is invalid.
- Specified by:
setInvalidin interfacecom.vaadin.flow.component.HasValidation- Overrides:
setInvalidin classGeneratedVaadinTextField<C extends AbstractNumberField<C,T>,T extends Number>- Parameters:
invalid- the boolean value to set
-
isInvalid
public boolean isInvalid()
- Specified by:
isInvalidin interfacecom.vaadin.flow.component.HasValidation
-
getDefaultValidator
public com.vaadin.flow.data.binder.Validator<T> getDefaultValidator()
- Specified by:
getDefaultValidatorin interfacecom.vaadin.flow.data.binder.HasValidator<C extends AbstractNumberField<C,T>>
-
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:
validatein classGeneratedVaadinTextField<C extends AbstractNumberField<C,T>,T extends Number>
-
setRequiredIndicatorVisible
public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
- Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
addThemeVariants
public void addThemeVariants(TextFieldVariant... variants)
- Specified by:
addThemeVariantsin interfaceHasThemeVariant<C extends AbstractNumberField<C,T>>
-
removeThemeVariants
public void removeThemeVariants(TextFieldVariant... variants)
- Specified by:
removeThemeVariantsin interfaceHasThemeVariant<C extends AbstractNumberField<C,T>>
-
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
VaadinServiceinstance to obtain the available feature flags, otherwise, the feature is considered disabled.- Parameters:
feature- the feature flag.- Returns:
- whether the feature flag is enabled.
-
-