Class NumberTextField<N extends Number & Comparable<N>>

    • Field Detail

      • ANY

        public static final Double ANY
        Use this as a marker of step attribute value "any" Because the w3c spec requires step to be a non-negative digit greater than zero we use zero as delegate for "any" keyword.
    • Constructor Detail

      • NumberTextField

        public NumberTextField​(String id)
        Construct.
        Parameters:
        id - The component id
      • NumberTextField

        public NumberTextField​(String id,
                               Class<N> type)
        Construct.
        Parameters:
        id - The component id
        type - The type to use when updating the model for this text field
      • NumberTextField

        public NumberTextField​(String id,
                               IModel<N> model)
        Construct.
        Parameters:
        id - The component id
        model - The input value
      • NumberTextField

        public NumberTextField​(String id,
                               IModel<N> model,
                               Class<N> type)
        Construct.
        Parameters:
        id - The component id
        model - The input value
        type - The type to use when updating the model for this text field
    • Method Detail

      • setMinimum

        public NumberTextField<N> setMinimum​(N minimum)
        Sets the minimum allowed value
        Parameters:
        minimum - the minimum allowed value
        Returns:
        this instance
      • setMaximum

        public NumberTextField<N> setMaximum​(N maximum)
        Sets the maximum allowed value
        Parameters:
        maximum - the maximum allowed value
        Returns:
        this instance
      • setStep

        public NumberTextField<N> setStep​(N step)
        Sets the step attribute
        Parameters:
        step - the step attribute
        Returns:
        this instance
      • setMinimum

        public NumberTextField<N> setMinimum​(IModel<N> minimum)
        Sets the minimum allowed value
        Parameters:
        minimum - the minimum allowed value
        Returns:
        this instance
      • setMaximum

        public NumberTextField<N> setMaximum​(IModel<N> maximum)
        Sets the maximum allowed value
        Parameters:
        maximum - the maximum allowed value
        Returns:
        this instance
      • setStep

        public NumberTextField<N> setStep​(IModel<N> step)
        Sets the step attribute
        Parameters:
        step - the step attribute
        Returns:
        this instance
      • onConfigure

        protected void onConfigure()
        Description copied from class: Component
        Called on all components before any component is rendered. This method should be used to configure such things as visibility and enabled flags.

        Overrides must call super.onConfigure(), usually before any other code

        NOTE: Component hierarchy should not be modified inside this method, instead it should be done in Component.onBeforeRender()

        NOTE: Why this method is preferrable to directly overriding Component.isVisible() and Component.isEnabled()? Because those methods are called multiple times even for processing of a single request. If they contain expensive logic they can slow down the response time of the entire page. Further, overriding those methods directly on form components may lead to inconsistent or unexpected state depending on when those methods are called in the form processing workflow. It is a better practice to push changes to state rather than pull.

        NOTE: If component's visibility or another property depends on another component you may call other.configure() followed by other.isVisible() as mentioned in Component.configure() javadoc.

        NOTE: Why should Component.onBeforeRender() not be used for this? Because if a component's visibility is controlled inside Component.onBeforeRender(), once invisible the component will never become visible again.

        Overrides:
        onConfigure in class Component
      • getInputTypes

        protected String[] getInputTypes()
        Description copied from class: TextField
        Subclass should override this method if this textfield is mapped on a different input type as text. Like PasswordTextField or HiddenField.
        Overrides:
        getInputTypes in class TextField<N extends Number & Comparable<N>>
        Returns:
        The input type of this textfield, default is null