Class BigDecimalField

  • All Implemented Interfaces:
    com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<BigDecimalField>, com.vaadin.flow.component.CompositionNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<BigDecimalField>, com.vaadin.flow.component.FocusNotifier<BigDecimalField>, 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<BigDecimalField,​BigDecimal>,​BigDecimal>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<BigDecimalField,​BigDecimal>,​BigDecimal>, com.vaadin.flow.component.InputNotifier, com.vaadin.flow.component.KeyNotifier, HasClearButton, HasThemeVariant<TextFieldVariant>, HasTooltip, HasAutocapitalize, HasAutocomplete, HasAutocorrect, HasPrefixAndSuffix, com.vaadin.flow.data.binder.HasValidator<BigDecimal>, com.vaadin.flow.data.value.HasValueChangeMode, Serializable

    @Tag("vaadin-big-decimal-field")
    @NpmPackage(value="@vaadin/polymer-legacy-adapter",
                version="23.6.1")
    @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("./vaadin-big-decimal-field.js")
    public class BigDecimalField
    extends GeneratedVaadinTextField<BigDecimalField,​BigDecimal>
    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, HasThemeVariant<TextFieldVariant>, HasTooltip, com.vaadin.flow.data.binder.HasValidator<BigDecimal>
    BigDecimalField is an input field for handling decimal numbers with high precision. This field uses BigDecimal as the server-side value type, and only allows numeric input.

    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).

    Author:
    Vaadin Ltd.
    See Also:
    Serialized Form
    • Constructor Detail

      • BigDecimalField

        public BigDecimalField()
        Constructs an empty BigDecimalField.
      • BigDecimalField

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

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

        public BigDecimalField​(String label,
                               BigDecimal initialValue,
                               String placeholder)
        Constructs a BigDecimalField with the given label, an initial value and placeholder text.
        Parameters:
        label - the text to set as the label
        initialValue - the initial value
        placeholder - the placeholder text to set
        See Also:
        AbstractField.setValue(Object), setPlaceholder(String)
      • BigDecimalField

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

        public BigDecimalField​(String label,
                               com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<BigDecimalField,​BigDecimal>> listener)
        Constructs an empty BigDecimalField with a label and a value change listener.
        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)
      • BigDecimalField

        public BigDecimalField​(String label,
                               BigDecimal initialValue,
                               com.vaadin.flow.component.HasValue.ValueChangeListener<? super com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<BigDecimalField,​BigDecimal>> listener)
        Constructs an empty BigDecimalField with a label,a value change listener 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<BigDecimalField,​BigDecimal>
        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<BigDecimalField,​BigDecimal>
        Parameters:
        invalid - the boolean 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
      • 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<BigDecimalField,​BigDecimal>
        Parameters:
        autoselect - true to set auto select on, false otherwise
      • isAutofocus

        public boolean isAutofocus()
        Specify that this control should have input focus when the page loads.
        Returns:
        the autofocus 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
      • setValue

        public void setValue​(BigDecimal value)
        Sets the value of this field. If the new value is not equal to 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.

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

        public BigDecimal getValue()
        Returns the current value of the field. By default, the empty BigDecimalField will return null.
        Specified by:
        getValue in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<BigDecimalField,​BigDecimal>,​BigDecimal>
        Overrides:
        getValue in class com.vaadin.flow.component.AbstractField<BigDecimalField,​BigDecimal>
        Returns:
        the current value.
      • 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<BigDecimalField,​BigDecimal>
      • setRequiredIndicatorVisible

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

        public void setLocale​(Locale locale)
        Sets the locale for this BigDecimalField. It is used to determine which decimal separator (the radix point) should be used.
        Parameters:
        locale - the locale to set, not null
      • getLocale

        public Locale getLocale()
        Gets the locale used by this BigDecimalField. It is used to determine which decimal separator (the radix point) should be used.
        Overrides:
        getLocale in class com.vaadin.flow.component.Component
        Returns:
        the locale of this field, never null
      • onAttach

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