6.56.  < rich:inputNumberSpinner >

6.56.1. Description

A single line input field that lets selecting a number using controls near a text field. It's possible to change a value using "Up/Down" keyboard keys. The keyboard input in a field is possible if it isn't locked by the "manualInput" attribute. When arrow controls are pressed, the cursor can be moved in any way without losing a dragged state.

<rich:InputNumberSpinner> component

Figure 6.134.  <rich:InputNumberSpinner> component


6.56.2. Key Features

  • Fully skinnable control and input elements

  • 3D look and feel with an easily customizable appearance

  • Attribute-managed positions of the controls (inside/outside of the input field)

  • Keyboard controls support

  • Optional disablement of the component on a page

  • Optional "cycled" mode of scrolling values

  • Optional manual/controls-only input into a value text field

  • Validation of manual input

Table 6.250. rich : inputNumberSpinner attributes

Attribute NameDescription
accesskeyThis attribute assigns an access key to an element. An access key is a single character from the document character set. Note: Authors should consider the input method of the expected reader when specifying an accesskey
bindingThe attribute takes a value-binding expression for a component property of a backing bean
clientErrorMessageclient error message
converterId of Converter to be used or reference to a Converter
converterMessageA ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
cycledIf "true" after the current value reaches the border value it is reversed to another border value after next increasing/decreasing. In other case possibilities of next increasing (or decreasing) will be locked
disabledWhen set for a form control, this boolean attribute disables the control for your input
enableManualInputif "false" your's input to the text field using keyboard will be locked
idEvery component may have a unique id that is automatically created if omitted
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
inputClassClass attribute for text field
inputSizeAttribute specifies the initial length of input in characters. Default value is 10
inputStyleStyle attribute for text field
labelA localized user presentable name for this component.
maxValueMaximum value
minValueMinimum value
onblurHTML: script expression; the element lost the focus
onchangeHTML: script expression; the element value was changed
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
ondownclickHTML: a script expression; a button "Down" is clicked
onerrorHTML: a script expression; event fires whenever an JavaScript error occurs
onfocusHTML: script expression; the element got the focus
oninputclickHTML: a script expression; a pointer button is clicked
oninputdblclickHTML: a script expression; a pointer button is double-clicked
oninputkeydownHTML: a script expression; a key is pressed down
oninputkeypressHTML: a script expression; a key is pressed and released
oninputkeyupHTML: a script expression; a key is released
oninputmousedownHTML: script expression; a pointer button is pressed down
oninputmousemoveHTML: a script expression; a pointer is moved within
oninputmouseoutHTML: a script expression; a pointer is moved away
oninputmouseoverHTML: a script expression; a pointer is moved onto
oninputmouseupHTML: script expression; a pointer button is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onselectHTML: script expression; The onselect event occurs when you select some text in a text field. This attribute may be used with the INPUT and TEXTAREA elements
onupclickHTML: a script expression; a button "Up" is clicked
renderedIf "false", this component is not rendered
requiredIf "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used
stepParameter that determines the step between nearest values while using controls
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
validatorMethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessageA ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
valueThe current value of this component
valueChangeListenerListener for value changes

Table 6.251. Component identification parameters

NameValue
component-typeorg.richfaces.inputNumberSpinner
component-classorg.richfaces.component.html.HtmlInputNumberSpinner
component-familyorg.richfaces.inputNumberSpinner
renderer-typeorg.richfaces.InputNumberSpinnerRenderer
tag-classorg.richfaces.taglib.InputNumberSpinnerTag

6.56.3. Creating the Component with a Page Tag

To create the simplest variant on a page use the following syntax:

Example:


...
    <rich:inputNumberSpinner minValue="0" maxValue="100" step="1"/> 
...

6.56.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlInputNumberSpinner;
...
HtmlInputNumberSpinner mySpinner = new HtmlInputNumberSpinner ();
...

6.56.5. Details of Usage

<rich:inputNumberSpinner> is used to facilitate your data input with rich UI Controls.

Here is the simplest variant of spinner definition with "minValue", "maxValue" and "step" (on default = "1") attributes, which define the beginning and the end of numerical area and a spinner step.

Example:


...
    <rich:inputNumberSpinner minValue="1" maxValue="100"/>
...

It generates on a page:

Generated <rich:InputNumberSpinner>

Figure 6.135. Generated <rich:InputNumberSpinner>


There are also several attributes to define functionality peculiarities:

  • "cycled" if the attribute is "true" after the current value reaches the border value it's be reversed to another border value after next increasing/decreasing. In other case possibilities of next increasing/decreasing are locked

  • "disabled" is an attribute that defines whether a component is active on a page

  • "manualInput" is an attribute that defines whether a keyboard input is possible or only UI controls could be used

Moreover, to add e.g. some JavaScript effects, events defined on it are used

  • onchange

  • onmouseover

  • onclick

  • onfocus

  • onmouseout

  • etc.

The "label" attribute is a generic attribute. The "label" attribute provides an association between a component, and the message that the component (indirectly) produced. This attribute defines the parameters of localized error and informational messages that occur as a result of conversion, validation, or other application actions during the request processing lifecycle. With the help of this attribute you can replace the last parameter substitution token shown in the messages. For example, {1} for “DoubleRangeValidator.MAXIMUM”, {2} for “ShortConverter.SHORT”.

6.56.6. Look-and-Feel Customization

For skinnability implementation, the components use a style class redefinition method. Default style classes are mapped on skin parameters.

There are two ways to redefine the appearance of all <rich:inputNumberSpinner> components at once:

  • Redefine the corresponding skin parameters

  • Add to your style sheets style classes used by a <rich:inputNumberSpinner> component

6.56.7. Skin Parameters Redefinition

Table 6.252. Skin parameters redefinition for a container

Skin parametersCSS properties
controlBackgroundColorbackground-color
panelBorderColorborder-color
subBorderColorborder-bottom-color
subBorderColorborder-right-color

Table 6.253. Skin parameters redefinition for an input field

Skin parametersCSS properties
buttonSizeFontfont-size
buttonFamilyFontfont-family

6.56.8. Definition of Custom Style Classes

On the screenshot there are classes names that define styles for component elements.

Style classes

Figure 6.136. Style classes


Table 6.254. Classes names that define a component appearance

Class nameDescription
rich-spinner-cDefines styles for a wrapper table element of a component
rich-spinner-input-containerDefines styles for a container
rich-spinner-inputDefines styles for an input field
rich-spinner-buttonDefines styles for a button

In order to redefine styles for all <rich:inputNumberSpinner> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the table above) and define necessary properties in them. An example is placed below:

Example:


...
.rich-spinner-input{
    
font-style:italic;
}
...

This is a result:

Redefinition styles with predefined classes

Figure 6.137. Redefinition styles with predefined classes


In the example an input text font style was changed.

Also it’s possible to change styles of particular <rich:inputNumberSpinner> component. In this case you should create own style classes and use them in corresponding <rich:inputNumberSpinner> styleClass attributes. An example is placed below:

Example:


...
.myClass{
    
font-family: Arial Black;
}
...

The "inputClass" attribute for <rich:inputNumberSpinner> is defined as it’s shown in the example below:

Example:


<rich: inputNumberSpinner ... inputClass="myClass"/>

This is a result:

Redefinition styles with own classes and styleClass attributes

Figure 6.138. Redefinition styles with own classes and styleClass attributes


As it could be seen on the picture above, the font family for input text was changed.

6.56.9. Relevant Resources Links

Here you can see the example of <rich:inputNumberSpinner> usage and sources for the given example.