@Tag(value="vaadin-big-decimal-field") @JsModule(value="./vaadin-big-decimal-field.js") public class BigDecimalField extends GeneratedVaadinTextField<BigDecimalField,BigDecimal> implements HasSize, HasValidation, HasValueChangeMode, HasPrefixAndSuffix, InputNotifier, KeyNotifier, CompositionNotifier, HasAutocomplete, HasAutocapitalize, HasAutocorrect, HasHelper
vaadin-big-decimal-field element. This
field uses BigDecimal as the server-side value type, which allows
handling decimal numbers with high precision. The component also prevents
users from entering characters which can't be used in a decimal number, such
as alphabets.
When setting values from the server-side, the scale of the provided
BigDecimal is preserved in the presentation format shown to the user,
as described in setValue(BigDecimal).
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_TIMEOUTAUTOCOMPLETE_ATTRIBUTEAUTOCAPITALIZE_ATTRIBUTEAUTOCORRECT_ATTRIBUTE| Constructor and Description |
|---|
BigDecimalField()
Constructs an empty
BigDecimalField. |
BigDecimalField(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<BigDecimalField,BigDecimal>> listener)
Constructs an empty
BigDecimalField with a value change listener. |
BigDecimalField(String label)
Constructs an empty
BigDecimalField with the given label. |
BigDecimalField(String label,
BigDecimal initialValue,
HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<BigDecimalField,BigDecimal>> listener)
Constructs an empty
BigDecimalField with a label,a value change
listener and an initial value. |
BigDecimalField(String label,
BigDecimal initialValue,
String placeholder)
Constructs a
BigDecimalField with the given label, an initial
value and placeholder text. |
BigDecimalField(String label,
HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<BigDecimalField,BigDecimal>> listener)
Constructs an empty
BigDecimalField with a label and a value
change listener. |
BigDecimalField(String label,
String placeholder)
Constructs an empty
BigDecimalField with the given label and
placeholder text. |
| Modifier and Type | Method and Description |
|---|---|
BigDecimal |
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.
|
Locale |
getLocale()
Gets the locale used by this BigDecimalField.
|
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.
|
BigDecimal |
getValue()
Returns the current value of the field.
|
ValueChangeMode |
getValueChangeMode()
Gets current value change mode of the component.
|
int |
getValueChangeTimeout()
Returns the currently set timeout, for how often
HasValue.ValueChangeEvents 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 field.
|
boolean |
isInvalid()
Returns
true if component input is invalid, false
otherwise. |
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 text
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)
Description copied from corresponding location in WebComponent:
|
void |
setLocale(Locale locale)
Sets the locale for this BigDecimalField.
|
void |
setPlaceholder(String placeholder)
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(BigDecimal value)
Sets the value of this field.
|
void |
setValueChangeMode(ValueChangeMode valueChangeMode)
Sets new value change mode for the component.
|
void |
setValueChangeTimeout(int valueChangeTimeout)
Sets how often
HasValue.ValueChangeEvents 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, setPattern, setPreventInvalidInput, setReadonly, setRequiredgetSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEventaddValueChangeListener, isEmpty, setModelValue, valueEqualsaddListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getParent, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, set, setElement, setId, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetCssSize, getHeight, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullgetPrefixComponent, getSuffixComponent, setPrefixComponent, setSuffixComponentaddInputListeneraddKeyDownListener, addKeyDownListener, addKeyPressListener, addKeyPressListener, addKeyUpListener, addKeyUpListeneraddCompositionEndListener, addCompositionStartListener, addCompositionUpdateListenergetAutocomplete, setAutocompletegetAutocapitalize, setAutocapitalizeisAutocorrect, setAutocorrectgetHelperComponent, getHelperText, setHelperComponent, setHelperTextgetElementaddClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameaddFocusShortcut, blur, focus, getTabIndex, setTabIndexaddBlurListeneraddFocusListenerisEnabled, setEnabledaddThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameisReadOnly, isRequiredIndicatorVisible, setReadOnlyclear, getOptionalValueaddAttachListeneraddDetachListenerpublic BigDecimalField()
BigDecimalField.public BigDecimalField(String label)
BigDecimalField with the given label.label - the text to set as the labelpublic BigDecimalField(String label, String placeholder)
BigDecimalField with the given label and
placeholder text.label - the text to set as the labelplaceholder - the placeholder text to setpublic BigDecimalField(String label, BigDecimal initialValue, String placeholder)
BigDecimalField with the given label, an initial
value and placeholder text.label - the text to set as the labelinitialValue - the initial valueplaceholder - the placeholder text to setAbstractField.setValue(Object),
setPlaceholder(String)public BigDecimalField(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<BigDecimalField,BigDecimal>> listener)
BigDecimalField with a value change listener.listener - the value change listenerAbstractField.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)public BigDecimalField(String label, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<BigDecimalField,BigDecimal>> listener)
BigDecimalField with a label and a value
change listener.label - the text to set as the labellistener - the value change listenersetLabel(String),
AbstractField.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)public BigDecimalField(String label, BigDecimal initialValue, HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<BigDecimalField,BigDecimal>> listener)
BigDecimalField with a label,a value change
listener 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 HasValueChangeModenull if
the value is not synchronizedpublic void setValueChangeMode(ValueChangeMode valueChangeMode)
HasValueChangeModesetValueChangeMode in interface HasValueChangeModevalueChangeMode - new value change mode, or null to disable the value
synchronizationpublic void setValueChangeTimeout(int valueChangeTimeout)
HasValueChangeModeHasValue.ValueChangeEvents are triggered when the
ValueChangeMode is set to ValueChangeMode.LAZY, or
ValueChangeMode.TIMEOUT.
Implementations should use
ValueChangeMode.applyChangeTimeout(ValueChangeMode, int, DomListenerRegistration).
setValueChangeTimeout in interface HasValueChangeModevalueChangeTimeout - the timeout in milliseconds of how often
HasValue.ValueChangeEvents are triggered.public int getValueChangeTimeout()
HasValueChangeModeHasValue.ValueChangeEvents are triggered when the ValueChangeMode is set
to ValueChangeMode.LAZY, or ValueChangeMode.TIMEOUT.getValueChangeTimeout in interface HasValueChangeModeHasValue.ValueChangeEvents are triggered.public String getErrorMessage()
HasValidationgetErrorMessage in interface HasValidationpublic void setErrorMessage(String errorMessage)
GeneratedVaadinTextFieldDescription copied from corresponding location in WebComponent:
Error to show when the input value is invalid.
setErrorMessage in interface HasValidationsetErrorMessage in class GeneratedVaadinTextField<BigDecimalField,BigDecimal>errorMessage - the String value to setpublic boolean isInvalid()
HasValidationtrue if component input is invalid, false
otherwise.isInvalid in interface HasValidationpublic void setInvalid(boolean invalid)
GeneratedVaadinTextFieldDescription copied from corresponding location in WebComponent:
This property is set to true when the control value is invalid.
setInvalid in interface HasValidationsetInvalid in class GeneratedVaadinTextField<BigDecimalField,BigDecimal>invalid - the boolean value to setpublic void setLabel(String label)
GeneratedVaadinTextFieldDescription copied from corresponding location in WebComponent:
String used for the label element.
setLabel in class GeneratedVaadinTextField<BigDecimalField,BigDecimal>label - the String value to setpublic String getLabel()
label property from the webcomponentpublic void setPlaceholder(String placeholder)
GeneratedVaadinTextFieldDescription copied from corresponding location in WebComponent:
A hint to the user of what can be entered in the control.
setPlaceholder in class GeneratedVaadinTextField<BigDecimalField,BigDecimal>placeholder - the String value to setpublic String getPlaceholder()
placeholder property from the webcomponentpublic 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<BigDecimalField,BigDecimal>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 text
field.setClearButtonVisible in class GeneratedVaadinTextField<BigDecimalField,BigDecimal>clearButtonVisible - true to set the button visible,
false otherwisepublic void setAutofocus(boolean autofocus)
GeneratedVaadinTextFieldDescription copied from corresponding location in WebComponent:
Specify that this control should have input focus when the page loads.
setAutofocus in class GeneratedVaadinTextField<BigDecimalField,BigDecimal>autofocus - the boolean value to setpublic boolean isAutofocus()
autofocus property from the webcomponentpublic String getTitle()
title property from the webcomponentpublic void setTitle(String title)
GeneratedVaadinTextFieldDescription 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<BigDecimalField,BigDecimal>title - the String value to setpublic BigDecimal 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<BigDecimalField,BigDecimal>,BigDecimal>getEmptyValue in class AbstractField<BigDecimalField,BigDecimal>public void setValue(BigDecimal value)
getValue(), fires a value change event.
You can adjust how the value is presented in the field with the APIs
provided by the value type BigDecimal. For example, you can
change the number of decimal places with
BigDecimal.setScale(int). This doesn't however restrict the user
from entering values with different number of decimals. Note that
BigDecimals are immutable, so their methods will return new instances
instead of editing the existing ones. Scientific notation (such as 1e9)
is turned into plain number format for the presentation.
setValue in interface HasValue<AbstractField.ComponentValueChangeEvent<BigDecimalField,BigDecimal>,BigDecimal>setValue in class AbstractField<BigDecimalField,BigDecimal>value - the new valuepublic BigDecimal getValue()
null.getValue in interface HasValue<AbstractField.ComponentValueChangeEvent<BigDecimalField,BigDecimal>,BigDecimal>getValue in class AbstractField<BigDecimalField,BigDecimal>protected void validate()
validate in class GeneratedVaadinTextField<BigDecimalField,BigDecimal>public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
HasValueIf 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<BigDecimalField,BigDecimal>,BigDecimal>setRequiredIndicatorVisible in interface HasValueAndElement<AbstractField.ComponentValueChangeEvent<BigDecimalField,BigDecimal>,BigDecimal>requiredIndicatorVisible - true to make the required indicator visible,
false if notpublic void setLocale(Locale locale)
locale - the locale to set, not nullpublic Locale getLocale()
protected void onAttach(AttachEvent attachEvent)
ComponentThe default implementation does nothing.
This method is invoked before the AttachEvent is fired for the
component.
Copyright © 2021. All rights reserved.