6.55.  < rich:inputNumberSlider >

6.55.1. Description

A component that lets selecting a number from a numeric region. It's a horizontal aligned scroll-like control with its own input field (optional) present. The keyboard input in a field is possible (optional). Also it's possible to see the current value in the toolTip above a dragged handle control.

<rich:InputNumberSlider> component

Figure 6.128.  <rich:InputNumberSlider> component


6.55.2. Key Features

  • Fully skinnable control and input elements

  • Optional value text field with an attribute-managed position

  • Optional disablement of the component on a page

  • Optional toolTip to display the current value while a handle is dragged

  • Dragged state is stable after the mouse moves

  • Optional manual input possible if a text input field is present

  • Validation of manual input

Table 6.243. rich : inputNumberSlider 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
barClassA name of CSS class for the bar element
barStyleStyle for a slider control line
bindingThe attribute takes a value-binding expression for a component property of a backing bean
clientErrorMessagean error message to use in client side validation events
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
disabledWhen set for a form control, this boolean attribute disables the control for your input
enableManualInputFalse value for this attribute makes a text field "read-only", so the value can be changed only from a handle
handleClassA name of CSS class for a control handle element
handleSelectedClassA name of CSS class for a selected control handle element
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
inputClassStyle Class attribute for a text field
inputPositionIf "right" the InputText Box would be rendered on the right side of the ruler
inputSizeSimilar to the "Size" attribute of h:inputText
inputStyleStyle attribute for text field
labelA localized user presentable name for this component.
maxlengthWhen the type attribute has the value "text" or "password", this attribute specifies the maximum number of characters you may enter. This number may exceed the specified size, in which case the user agent should offer a scrolling mechanism. The default value for this attribute is an unlimited number
maxValueAttribute to set an "end" value
minValueAttribute to set a "start" 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
onerrorThis error is called when a non-number value or a number value that is out of the range is input
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
onslideEvent occur on slide
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
showBoundaryValuesIf the min/max values are shown on the right/left borders of a control. Default=true
showInputFalse value for this attribute makes text a field invisible
showToolTipIf the current value will be shown in the tooltip when a handle control in a "dragged" state.Default=true.
stepParameter that determines a step between the nearest values while using a handle
styleStyles for main div element of the slider control
styleClassName of a CSS class
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
tipClassA name of CSS class for the tool tip element
tipStyleA style for the tool tip element
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
widthThe width of a slider control

Table 6.244. Component identification parameters

NameValue
component-typeorg.richfaces.inputNumberSlider
component-classorg.richfaces.component.html.HtmlInputNumberSlider
component-familyorg.richfaces.inputNumberSlider
renderer-typeorg.richfaces.InputNumberSliderRenderer
tag-classorg.richfaces.taglib.InputNumberSliderTag

6.55.3. Creating the Component with a Page Tag

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

Example:


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

6.55.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlInputNumberSlider;
...
HtmlInputNumberSlider mySlider = new HtmlInputNumberSlider();
...

6.55.5. Details of Usage

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

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

Example:


<rich:inputNumberSlider></rich:inputNumberSlider>

It generates on a page:

Generated <rich:InputNumberSlider>

Figure 6.129. Generated <rich:InputNumberSlider>


Using "showInput" (default is true) and "enableManualInput" (default value is true) attributes, it's possible to output the input area near the slider, and make it read-only or editable.

To remove input area use "showInput="false" :

Example:


<rich:inputNumberSlider minValue="1"  maxValue="100" showInput="false"/>

It looks at page like:

<rich:inputNumberSlider> without input field

Figure 6.130.  <rich:inputNumberSlider> without input field


It's also possible to switch off displaying of "boundary values" and a toolTip showing on a handle drawing. This could be performed with the help of the component defined attributes: "showBoundaryValues" which is responsible for "boundary values" displaying (default is true) and "showToolTip" which is responsible for tooltTip displaying (default is true).

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.55.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:inputNumberSlider> components at once:

  • Redefine the corresponding skin parameters

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

6.55.7. Skin Parameters Redefinition

Table 6.245. Skin parameters redefinition for a bar

Skin parametersCSS properties
controlBackgroundColorbackground-color

Table 6.246. Skin parameters redefinition for numbers

Skin parametersCSS properties
generalFamilyFontfont-family
generalSizeFontfont-size
generalTextColorcolor
panelBorderColorborder-color
generalSizeFontline-height

Table 6.247. Skin parameters redefinition for a text field

Skin parametersCSS properties
controlBackgroundColorbackground-color
generalFamilyFontfont-family
generalSizeFontfont-size
controlTextColorcolor
panelBorderColorborder-color
subBorderColorborder-bottom-color
subBorderColorborder-right-color

Table 6.248. Skin parameters redefinition for a hint

Skin parametersCSS properties
tipBackgroundColorbackground-color
tipBorderColorborder-color
generalFamilyFontfont-family
generalSizeFontfont-size

6.55.8. Definition of Custom Style Classes

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

Style classes

Figure 6.131. Style classes


Table 6.249. Classes names that define a component appearance

Class nameDescription
rich-sliderDefines styles for a wrapper table element of a component
rich-inslider-trackDefines styles for a bar
rich-inslider-handlerDefines styles for a slider handler
rich-inslider-handler-selectedDefines styles for a selected handler
rich-inslider-fieldDefines styles for a text field
rich-inslider-right-numDefines styles for the right number
rich-inslider-left-numDefines styles for the left number
rich-inslider-tipDefines styles for a hint

In order to redefine styles for all <rich:inputNumberSlider> 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-inslider-tip{
    
background-color: #FFDAB9;
    
font-family: Arial Black;
}  
...

This is a result:

Redefinition styles with predefined classes

Figure 6.132. Redefinition styles with predefined classes


In the example a tip background color and font family was changed.

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

Example:


...
.myClass{
    
font-style: italic;
    
font-weight:bold;
    
font-size:12px;
}
...

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

Example:


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

This is a result:

Redefinition styles with own classes and styleClass attributes

Figure 6.133. Redefinition styles with own classes and styleClass attributes


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

6.55.9. Relevant Resources Links

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