Class WNumberField

    • Constructor Detail

      • WNumberField

        public WNumberField()
    • Method Detail

      • getValueAsString

        public String getValueAsString()
        Description copied from class: AbstractInput
        Retrieves a String representation of the input field's value.
        Specified by:
        getValueAsString in interface Input
        Overrides:
        getValueAsString in class AbstractInput
        Returns:
        the number value, or the text entered by the user if there is no valid number.
      • doHandleRequest

        protected boolean doHandleRequest​(Request request)
        Specific handle request processing for an input component is provided here.

        Input components are required to determine if the component has changed in the request, set the component data to the new value (if changed) and return the changed flag.

        Specified by:
        doHandleRequest in class AbstractInput
        Parameters:
        request - the request being responded to.
        Returns:
        true if the input component has changed, otherwise return false
      • handleRequestValue

        protected void handleRequestValue​(BigDecimal value,
                                          boolean valid,
                                          String text)
        Set the request value.
        Parameters:
        value - the number value
        valid - true if valid value
        text - the user text
      • getRequestValue

        public BigDecimal getRequestValue​(Request request)
        Provide the value of the component on the Request.

        If the component is not on the request, the components current value will be provided.

        Specified by:
        getRequestValue in interface Input
        Parameters:
        request - the request being responded to.
        Returns:
        the value of this component on the Request, or its current state if it is not on the request.
      • getValue

        public BigDecimal getValue()
        Retrieves the numeric value of this field.
        Specified by:
        getValue in interface Input
        Overrides:
        getValue in class AbstractInput
        Returns:
        the numeric value, or null if the field does not contain a valid number.
      • getText

        public String getText()
        Retrieves the text as entered by the user. This is not necessarily a valid date.
        Returns:
        the text, as entered by the user.
      • isValidNumber

        public boolean isValidNumber()
        Indicates whether the text value held in this field is a valid number.
        Returns:
        true if the field contains text which is a valid number, false otherwise.
      • getNumber

        public BigDecimal getNumber()
        Retrieves the numeric value of this field.
        Returns:
        the numeric value, or null if the field does not contain a valid number.
      • setData

        public void setData​(Object data)
        Sets the data that this component displays/edits. For bean aware components, this should only be called from handleRequest to set user-entered data.
        Specified by:
        setData in interface DataBound
        Overrides:
        setData in class WBeanComponent
        Parameters:
        data - the data to set
      • setNumber

        public void setNumber​(BigDecimal value)
        Sets the value of this number field.
        Parameters:
        value - the value to set.
      • setNumber

        public void setNumber​(long value)
        Sets the value of this number field.
        Parameters:
        value - the value.
      • setNumber

        public void setNumber​(double value)
        Sets the value of this number field.
        Parameters:
        value - the value to set.
      • setValue

        @Deprecated
        public void setValue​(long value)
        Deprecated.
        Sets the value of this number field.
        Parameters:
        value - the value.
      • setValue

        @Deprecated
        public void setValue​(double value)
        Deprecated.
        Sets the value of this number field.
        Parameters:
        value - the value to set.
      • getMinValue

        public BigDecimal getMinValue()
        Retrieves the minimum allowable value for this number field. The minimum value is enforced server-side using the WComponent validation framework, and may be enforced client-side.
        Returns:
        the minimum allowable value, or null if there is no minimum.
      • setMinValue

        public void setMinValue​(long minValue)
        Sets the minimum allowable value for this number field.
        Parameters:
        minValue - the minimum allowable value.
      • setMinValue

        public void setMinValue​(double minValue)
        Sets the minimum allowable value for this number field.
        Parameters:
        minValue - the minimum allowable value.
      • setMinValue

        public void setMinValue​(BigDecimal minValue)
        Sets the minimum allowable value for this number field.
        Parameters:
        minValue - the minimum allowable value, or null for no minimum.
      • getMaxValue

        public BigDecimal getMaxValue()
        Retrieves the maximum allowable value for this number field. The minimum value is enforced server-side using the WComponent validation framework, and may be enforced client-side.
        Returns:
        the maximum allowable value, or null if there is no maximum.
      • setMaxValue

        public void setMaxValue​(long maxValue)
        Sets the maximum allowable value for this number field.
        Parameters:
        maxValue - the maximum allowable value.
      • setMaxValue

        public void setMaxValue​(double maxValue)
        Sets the maximum allowable value for this number field.
        Parameters:
        maxValue - the maximum allowable value.
      • setMaxValue

        public void setMaxValue​(BigDecimal maxValue)
        Sets the maximum allowable value for this number field.
        Parameters:
        maxValue - the maximum allowable value, or null for no maximum.
      • getStep

        public BigDecimal getStep()
        Retrieves the step value for this number field. The step may be used by some user agents to provide a convenient increment/decrement function, such to a spinner control.
        Returns:
        the step value, or null if there is no step value set.
      • setStep

        public void setStep​(long step)
        Sets the step value for this field.
        Parameters:
        step - the step value.
      • setStep

        public void setStep​(double step)
        Sets the step value for this field.
        Parameters:
        step - the step value.
      • setStep

        public void setStep​(BigDecimal step)
        Sets the step value for this field.
        Parameters:
        step - the step value, or null to use the default step.
      • getDecimalPlaces

        public int getDecimalPlaces()
        Retrieves the number of decimal places to use for this number field. A value of zero indicates that the fields should only accept integer values.
        Returns:
        the number of decimal places to use.
      • setDecimalPlaces

        public void setDecimalPlaces​(int decimalPlaces)
        Sets the number of decimal places to use for this field.
        Parameters:
        decimalPlaces - the number of decimal places.
      • getColumns

        @Deprecated
        public int getColumns()
        Deprecated.
        1.3 size not used as it is incompatible with HTML specification.
        Returns:
        the width of the input field in characters.
      • setColumns

        @Deprecated
        public void setColumns​(int columns)
        Deprecated.
        1.3 size not used as it is incompatible with HTML specification.
        Sets the width of the input field in characters.
        Parameters:
        columns - the number of characters to display.
      • validateComponent

        protected void validateComponent​(List<Diagnostic> diags)
        Override WInput's validateComponent to perform futher validation on email addresses.
        Overrides:
        validateComponent in class AbstractInput
        Parameters:
        diags - the list into which any validation diagnostics are added.
      • validateNumber

        protected void validateNumber​(List<Diagnostic> diags)

        Performs validation of the number. Validation ensures that the entered text is a valid number, and is between the minimum/maximum values (if applicable).

        Subclasses can override this method to perform more specific validation.

        Parameters:
        diags - the list into which any validation diagnostics are added.
      • getComponentModel

        protected WNumberField.NumberFieldModel getComponentModel()
        Returns the effective component model for this component. Subclass may override this method to narrow the return type to their specific model type.
        Overrides:
        getComponentModel in class AbstractInput
        Returns:
        the effective component model
      • getOrCreateComponentModel

        protected WNumberField.NumberFieldModel getOrCreateComponentModel()
        Retrieves the model for this component so that it can be modified. If this method is called during request processing, and a session specific model does not yet exist, then a new model is created. Subclasses may override this method to narrow the return type to their specific model type.
        Overrides:
        getOrCreateComponentModel in class AbstractInput
        Returns:
        the model for this component
      • getAutocomplete

        public String getAutocomplete()
        Specified by:
        getAutocomplete in interface Autocompleteable
        Returns:
        the value of the autocomplete attribute applied to the current field.
      • addAutocompleteSection

        public void addAutocompleteSection​(String sectionName)
        Description copied from interface: Autocompleteable
        Pre-pend an autocomplete section to the value of an autocomplete attribute for the current field.
        Specified by:
        addAutocompleteSection in interface Autocompleteable
        Parameters:
        sectionName - the name of the section being the part which would replace the asterisk in the form section-*