Class IntegerItem

All Implemented Interfaces:
Animatable<IntegerItem>, CanDrop<IntegerItem>, Clickable<IntegerItem>, SupportAppend<IntegerItem>, SupportHelpIcon<IntegerItem>, SupportPlaceholder<IntegerItem>, Draggable<IntegerItem>, Editable<IntegerItem>, Focusable<IntegerItem>, HandleHotKey<IntegerItem>, HandleKeyboardEvents<IntegerItem>, HandleMouseEvents<IntegerItem>, Touchable<IntegerItem>

Integer item

Input field used to enter integers. The component prompts the user to enter an integer. The component displays an input field on the interface where the user enters only numeric characters. A plus and a minus icon are also displayed in order for the user to increment/decrement the component’s value.

A minimum and a maximum value can also be set for the component. In this case the user is only allowed to enter a value into the component within the specified range and the step of incrementing/decrementing the value is set.

The integer item component is a form item which means the component can be placed on the Form component and the form fully supports its functionality. The component is also suitable for standalone use, but in this case its values and events must be handled from code.

Supported events:

AnimationStart AnimationEnd, Focus FocusOut FocusIn LosesFocus copy cut EnterPressed input paste Click, DoubleClick, MouseDown, MouseDown, MouseLeave, MouseMove, MouseOver, MouseOut, MouseUp, Wheel, KeyPress, KeyUp, KeyDown, TouchCancel, TouchEnd, TouchMove, TouchStart, Drop, DragStart, DragEnd HotKey

Since:
4.0
Author:
JBStrap
See Also:
  • Constructor Details

    • IntegerItem

      public IntegerItem(String name, String label)
      Creates an integer input field with the specified name and label.
      Parameters:
      name - Input field name
      label - Input field label If null is set, the field has no label.
      Throws:
      NullPointerException - Thrown if the specified name for the field is null
    • IntegerItem

      public IntegerItem(String name, String label, String language)
      Creates an integer input field with the specified name and label according to the specified language code.
      Parameters:
      name - Input field name
      label - Input field label If null is set, the field has no label.
      language - The language code used to create the field If not specified or set to null, the field is created using the default language of the framework. The default language of the framework is set via the JBStrap parameter JBStrapParamType.DEFAULT_LANGUAGE.
      Throws:
      NullPointerException - Thrown if the specified name for the field is null
    • IntegerItem

      public IntegerItem(DataDescriptorColumn column)

      Creates an integer input field from a DataDescriptor column.

      The method creates and sets an integer input field based on the parameter-specified DataDescriptor column. The following parameters of the DataDescriptor are used:

      • DataDescriptorColumn.getTitle - The field label is the one specified for the DataDescriptor column
      • DataDescriptorColumn.isNullable() - If the field gets a value of null, it is not designated as mandatory. If the field value is not set to null, it is designated as a mandatory field.
      • MetaParamName.MIN_VALUE - This parameter specifies the minimum value of the component The parameter must take a value that can be converted to Long. If the parameter is not specified, no lower bound is set for the component value.
      • MetaParamName.MAX_VALUE - This parameter specifies the maximum value of the component. The parameter must take a value that can be converted to Long. If the parameter is not specified, no upper bound is set for the component value.
      • MetaParamName.TOUCHSPIN_STEP - This parameter specifies the increment/decrement step. The default value is 1. The parameter must take a value that can be converted to Long.
      • MetaParamName.TOUCHSPIN_BUTTONUP_CLASS - This parameter specifies the custom CSS class for the increment button
      • MetaParamName.TOUCHSPIN_BUTTONDOWN_CLASS - This parameter specifies the custom CSS class for the decrement button
      • MetaParamName.TOUCHSPIN_PREFIX - If a text is set in the parameter, it is displayed as a prefix in front of the input field.
      • MetaParamName.TOUCHSPIN_PREFIX_EXTRACLASS - If a prefix is displayed in front of the input field, the custom CSS class containing the prefix is specified here
      • MetaParamName.TOUCHSPIN_POSTFIX - If a text is specified in the parameter, it is displayed next to the input field as a postfix.
      • MetaParamName.TOUCHSPIN_POSTFIX_EXTRACLASS - If a postfix comes after the input field, the CSS class for the postfix box is specified here
      • MetaParamName.TOUCHSPIN_VERTICALBUTTONS - If the value is set to true, increment and decrement buttons are displayed below each other on the right side of the component. By default, the decrement button is displayed on the left side of the input field, whereas the increment button is displayed on the right side of the input field.
      • MetaParamName.MOUSEWHEEL - If the parameter is set to true, the user is able to change the component value by using the mouse wheel. This function is disabled by default.
      • MetaParamName.PLACEHOLDER - Placeholder text to be used in the input field. This text is displayed if no other text is entered into the input field.
      • MetaParamName.SIZE - The input field size is set from the value specified here. (Available values: SMALL, MEDIUM, LARGE)
      • MetaParamName.STATE - The input field state is set from these values. (Available values: DEFAULT, ERROR, WARNING, SUCCESS, INFO)
      • MetaParamName.DEFAULT_VALUE - The value specified here is set as the input field’s default value. The value must be specified based on the field’s data type, that is, it must be a text value.
      • MetaParamName.READ_ONLY - If true is set, the field is created as a read-only field. Otherwise the field is created as writable and the user is free to change its content.
      • MetaParamName.ENABLED - If false is set, the field is disabled. In all other cases the field is created as enabled.
      • MetaParamName.HELP - If this parameter is specified, an icon is displayed next to the input field and the text specified here appears as a help text if the user moves the mouse over it.
      • MetaParamName.HELP_ICON - If an icon name is specified in the parameter, also listed in the enum Icon, the default help text is changed to the icon.
      • MetaParamName.DESCRIPTION - The text specified here will appear below the field, in a smaller, italic font.
      • MetaParamName.TAB_INDEX - The value specified here determines the order of the input focus (when the user presses the Tab key). The smaller the value is, the sooner the field gets focus. The greater the value is, the later the field gets focus. If the parameter is not specified, the field’s tab index receives the focus order value set for the field in the DataDescriptor. If that is also not specified, the focus order is based on which data value was entered earlier into the DataDescriptor.

      Parameters:
      column - The DataDescriptor column based on which the field is created
      Throws:
      NullPointerException - Thrown if the parameter’s specified column is set to null
      NumberFormatException - Thrown if the value of the parameters MIN_VALUE, MAX_VALUE vagy a TOUCHSPIN_STEP cannot be parsed to Long.
    • IntegerItem

      public IntegerItem(DataDescriptorColumn column, String language)

      Creates an integer input field based on the specified DataDescriptor column and language code.

      The method creates and sets an integer input field based on the parameter-specified DataDescriptor column. The following parameters of the DataDescriptor are used:

      • DataDescriptorColumn.getTitle - The field label is the one specified for the DataDescriptor column
      • DataDescriptorColumn.isNullable() - If the field gets a value of null, it is not designated as mandatory. If the field value is not set to null, it is designated as a mandatory field.
      • MetaParamName.MIN_VALUE - This parameter specifies the minimum value of the component The parameter must take a value that can be converted to Long. If the parameter is not specified, no lower bound is set for the component value.
      • MetaParamName.MAX_VALUE - This parameter specifies the maximum value of the component. The parameter must take a value that can be converted to Long. If the parameter is not specified, no upper bound is set for the component value.
      • MetaParamName.TOUCHSPIN_STEP - This parameter specifies the increment/decrement step. The default value is 1. The parameter must take a value that can be converted to Long.
      • MetaParamName.TOUCHSPIN_BUTTONUP_CLASS - This parameter specifies the custom CSS class for the increment button
      • MetaParamName.TOUCHSPIN_BUTTONDOWN_CLASS - This parameter specifies the custom CSS class for the decrement button
      • MetaParamName.TOUCHSPIN_PREFIX - If a text is set in the parameter, it is displayed as a prefix in front of the input field.
      • MetaParamName.TOUCHSPIN_PREFIX_EXTRACLASS - If a prefix is displayed in front of the input field, the custom CSS class containing the prefix is specified here
      • MetaParamName.TOUCHSPIN_POSTFIX - If a text is specified in the parameter, it is displayed next to the input field as a postfix.
      • MetaParamName.TOUCHSPIN_POSTFIX_EXTRACLASS - If a postfix comes after the input field, the CSS class for the postfix box is specified here
      • MetaParamName.TOUCHSPIN_VERTICALBUTTONS - If the value is set to true, increment and decrement buttons are displayed below each other on the right side of the component. By default, the decrement button is displayed on the left side of the input field, whereas the increment button is displayed on the right side * of the input field.
      • MetaParamName.MOUSEWHEEL - If the parameter is set to true, the user is able to change the component value by using the mouse wheel. This function is disabled by default.
      • MetaParamName.PLACEHOLDER - Placeholder text to be used in the input field. This text is displayed if no other text is entered into the input field.
      • MetaParamName.SIZE - The input field size is set from the value specified here. (Available values: SMALL, MEDIUM, LARGE)
      • MetaParamName.STATE - The input field state is set from these values. (Available values: DEFAULT, ERROR, WARNING, SUCCESS, INFO)
      • MetaParamName.DEFAULT_VALUE - The value specified here is set as the input field’s default value. The value must be specified based on the field’s data type, that is, it must be a text value.
      • MetaParamName.READ_ONLY - If true is set, the field is created as a read-only field. Otherwise the field is created as writable and the user is free to change its content.
      • MetaParamName.ENABLED - If false is set, the field is disabled. In all other cases the field is created as enabled.
      • MetaParamName.HELP - If this parameter is specified, an icon is displayed next to the input field and the text specified here appears as a help text if the user moves the mouse over it.
      • MetaParamName.HELP_ICON - If an icon name is specified in the parameter, also listed in the enum Icon, the default help text is changed to the icon.
      • MetaParamName.DESCRIPTION - The text specified here will appear below the field, in a smaller, italic font.
      • MetaParamName.TAB_INDEX - The value specified here determines the order of the input focus (when the user presses the Tab key). The smaller the value is, the sooner the field gets focus. The greater the value is, the later the field gets focus. If the parameter is not specified, the field’s tab index receives the focus order value set for the field in the DataDescriptor. If that is also not specified, the focus order is based on which data value was entered earlier into the DataDescriptor.
      • MetaParamName.SHOW_BUTTONS - This parameter determines if the buttons are shown on the component. By default, the buttons are not shown. If true, the buttons will be displayed in the component's input field

      Parameters:
      column - The DataDescriptor column based on which the field is created
      language - The language code used to create the field If not specified or set to null, the field is created using the default language of the framework. The default language of the framework is set via the JBStrap parameter JBStrapParamType.DEFAULT_LANGUAGE.
      Throws:
      NullPointerException - Thrown if the parameter’s specified column is set to null
      NumberFormatException - Thrown if the value of the parameters MIN_VALUE, MAX_VALUE vagy a TOUCHSPIN_STEP cannot be parsed to Long.
  • Method Details

    • getMinimumValue

      public final Long getMinimumValue()
      Gets the minimum value for the component
      Returns:
      The minimum value for the component or null if no minimum value is set
    • setMinimumValue

      public final IntegerItem setMinimumValue(Number minValue)
      Sets the minimum value for the component.
      Parameters:
      minValue - The minimum value of the component No smaller value is allowed to be set for this component.
      Returns:
      Integer input component
    • getMaximumValue

      public final Long getMaximumValue()
      Gets the maximum value for the component.
      Returns:
      The maximum value for the component or null if the maximum value is not specified
    • setMaximumValue

      public final IntegerItem setMaximumValue(Number maxValue)
      Sets the component’s maximum value.
      Parameters:
      maxValue - The maximum value for the component No greater value is allowed to be set for this component.
      Returns:
      Integer input component
    • setValue

      public final IntegerItem setValue(Long value)
      Sets the current value of the component.
      Overrides:
      setValue in class FormItem<Long,IntegerItem>
      Parameters:
      value - The current value of the component
      Returns:
      Integer input component
    • setOriginalValue

      public final IntegerItem setOriginalValue(Long value)
      Sets the original value of the component
      Overrides:
      setOriginalValue in class FormItem<Long,IntegerItem>
      Parameters:
      value - The current value of the component
      Returns:
      Integer input component
    • setObjectValue

      public IntegerItem setObjectValue(Object value)
      Description copied from class: FormItem
      Sets the form item’s current value using the object in the parameter.
      Overrides:
      setObjectValue in class FormItem<Long,IntegerItem>
      Parameters:
      value - The current value of the component
      Returns:
      Integer input component
      Throws:
      NumberFormatException - Thrown if the text equivalent of the specified value cannot be ?????
    • setOriginalObjectValue

      public IntegerItem setOriginalObjectValue(Object value)
      Description copied from class: FormItem
      Sets the form item’s original value using the object in the parameter.
      Overrides:
      setOriginalObjectValue in class FormItem<Long,IntegerItem>
      Parameters:
      value - The original value of the component
      Returns:
      Integer input component
      Throws:
      NumberFormatException - Thrown if the text equivalent of the specified value cannot be ?????
    • isShowTouchSpin

      public final boolean isShowTouchSpin()
      Sets if the increment/decrement buttons are displayed on the interface.
      Returns:
      If true, the increment/decrement buttons are visible, otherwise false
    • setShowTouchSpin

      public final IntegerItem setShowTouchSpin(boolean showTouchSpin)
      Sets the appearance of the increment/decrement button. By default, the increment/decrement buttons are hidden on the interface.
      Parameters:
      showTouchSpin - If true is set, the increment/decrement buttons are visible If false is set, the increment/decrement buttons are not displayed.
      Returns:
      Integer input component
    • setStep

      public final IntegerItem setStep(Number step)
      Sets the increment/decrement value specified by the buttons. By default, the value is incremented/decremented in a step of 1.
      Parameters:
      step - Increment/decrement step
      Returns:
      Integer input component
    • getStep

      public final Number getStep()
      Gets the increment/decrement value set by the buttons.
      Returns:
      Increment/decrement step
    • setPrefix

      public final IntegerItem setPrefix(String prefixText)
      Sets the input box prefix.
      Parameters:
      prefixText - Prefix text
      Returns:
      Integer input component
    • setPrefix

      public final IntegerItem setPrefix(String prefixText, String prefixStyleClass)
      Sets the input box prefix and the custom style class of the prefix box.
      Parameters:
      prefixText - Prefix
      prefixStyleClass - Prefix box style class
      Returns:
      Integer input component
    • getPrefix

      public final String getPrefix()
      Gets the prefix text.
      Returns:
      The prefix text or null if no prefix is set for the component
    • setPostfix

      public final IntegerItem setPostfix(String postfixText)
      Sets the postfix text to be displayed after the input box.
      Parameters:
      postfixText - Postfix text
      Returns:
      Integer input component
    • setPostfix

      public final IntegerItem setPostfix(String postfixText, String postfixStyleClass)
      Sets the postfix text and the custom style class for the postfix.
      Parameters:
      postfixText - Postfix text
      postfixStyleClass - The name of the style class for the postfix box
      Returns:
      Integer input component
    • getPostfix

      public final String getPostfix()
      Sets the postfix text to be displayed after the input box.
      Returns:
      Postfix text or null if no postfix is set for the component
    • setTouchSpinButtonClass

      public final IntegerItem setTouchSpinButtonClass(String downButtonClass, String upButtonClass)
      Custom style class for the increment/decrement buttons.
      Parameters:
      downButtonClass - The style class for the decrement button
      upButtonClass - The style class for the increment button
      Returns:
      Integer input component
    • getUpButtonStyleClass

      public final String getUpButtonStyleClass()
      Gets the style class for the increment button.
      Returns:
      The style class for the increment button or null if the increment button has no defined custom style class
    • getDownButtonStyleClass

      public final String getDownButtonStyleClass()
      Gets the style class name for the decrement button.
      Returns:
      Style class name for the decrement button or null if the decrement button has no custom style class defined
    • setTouchSpinVertical

      public final IntegerItem setTouchSpinVertical(boolean vertical)
      Sets the alignment of the increment/decrement buttons. By default, increment/decrement buttons are located to the left and right of the input field. This settings may be changed so that buttons are below each other to the right of the input field.
      Parameters:
      vertical - If true is set, increment/decrement buttons are located below each other to the right of the input field. If false is set , increment/decrement buttons are located to the left and right of the input field.
      Returns:
      Integer input component
    • isTouchSpinVertical

      public final boolean isTouchSpinVertical()
      Sets if the increment/decrement buttons are displayed below each other.
      Returns:
      If true is set, increment/decrement buttons are located below each other to the left of the input field. Otherwise false.
    • drawEditor

      public void drawEditor(StringWriter writer)
      Description copied from class: FormItem

      Draws the editor component.

      You do not need to use this method during development, but all components extending the form item must implement it. Use the method to generate the input field’s HTML code. This code is then inserted into the corresponding DOM code when drawing the form item.

      Specified by:
      drawEditor in class FormItem<Long,IntegerItem>
      Parameters:
      writer - The HTML string writer class instance; write here the HTML code for the input field
    • init

      public void init() throws JavaScriptLoadError
      Description copied from class: Component
      The component initialization method.

      Empty method, only needs to be overwritten when making a custom component, that needs to call an initializing JavaScript on the client side. The method is called by the framework after the component is drawn, but before the afterDraw() method. The use of this method during application development is not allowed. This method is meant for inner use only.

      Overrides:
      init in class FormItem<Long,IntegerItem>
      Throws:
      JavaScriptLoadError - If there was a JavaScript error during the initialization.
    • setDefaultValue

      public IntegerItem setDefaultValue(Object defaultValue)
      Sets input field default value.
      Specified by:
      setDefaultValue in class FormItem<Long,IntegerItem>
      Parameters:
      defaultValue - The default value for the input field
      Returns:
      Form item component
      Throws:
      NumberFormatException - Thrown if the specified value cannot be interpreted as Long
    • afterDraw

      public void afterDraw()
      Description copied from class: Component
      The operations to be executed after the drawing of the component

      By default, this is an empty method. It has to be overwritten on a component or page if additional operations have to be executed after the drawing process. One such operation is data retrieval, which shouldn't run in constructors so that the user could see results of an operation or navigation process.

      Overrides:
      afterDraw in class FormItem<Long,IntegerItem>
    • setReadOnly

      public IntegerItem setReadOnly(boolean readOnly)
      Sets if the field is read-only. If the field is set to read-only, the user is not allowed to change or modify the input field value using the increment/decrement buttons. Modifications are allowed by default.
      Overrides:
      setReadOnly in class FormItem<Long,IntegerItem>
      Parameters:
      readOnly - If true is set, the field is read-only, otherwise it modifications are allowed
      Returns:
      Integer input component
    • isReadOnly

      public boolean isReadOnly()
      Sets if the input field is read-only.
      Overrides:
      isReadOnly in class FormItem<Long,IntegerItem>
      Returns:
      If true is set, the input field is read-only, otherwise modifications are allowed
    • setEnabled

      public IntegerItem setEnabled(boolean enabled)
      Enabling/disabling the component on the interface. If the component is disabled, the user is not allowed to use it and change its value. By default the component is enabled.
      Overrides:
      setEnabled in class FormItem<Long,IntegerItem>
      Parameters:
      enabled - If true is set, the component is enabled, otherwise disabled
      Returns:
      Integer input component
    • isEnabled

      public boolean isEnabled()
      Sets if the component is enabled.
      Overrides:
      isEnabled in class Component<IntegerItem>
      Returns:
      If true is set, the component is enabled, otherwise disabled
    • setMousewheelSupport

      public final IntegerItem setMousewheelSupport(boolean mousewheel)
      Sets if mouse wheel is supported. If the mouse wheel is supported, the input box value can be incremented/decremented using the mouse wheel. This function is disabled by default.
      Parameters:
      mousewheel - If true is set, the mouse wheel can be used to increment/decrement component value, otherwise not.
      Returns:
      Integer input component
    • isMousewheelSupport

      public final boolean isMousewheelSupport()
      Sets if the component value is allowed to be modified using the mouse wheel.
      Returns:
      If true the component value can be modified using the mouse wheel, otherwise not.