JBoss.orgCommunity Documentation

Chapter 9. Rich inputs

9.1. <rich:autocomplete>
9.1.1. Basic usage
9.1.2. Interactivity options
9.1.3. Customizing the filter
9.1.4. JavaScript API
9.1.5. Reference data
9.2. <rich:calendar>
9.2.1. Basic usage
9.2.2. Behavior and appearance
9.2.3. Time of day
9.2.4. Localization and formatting
9.2.5. Using a data model
9.2.6. Client-side customization
9.2.7. JavaScript API
9.2.8. Reference data
9.3. <rich:fileUpload>
9.3.1. Basic usage
9.3.2. Upload settings
9.3.3. Interactivity options
9.3.4. <rich:fileUpload> client-side events
9.3.5. Reference data
9.4. <rich:inplaceInput>
9.4.1. Basic usage
9.4.2. Interactivity options
9.4.3. JavaScript API
9.4.4. Reference data
9.5. <rich:inplaceSelect>
9.5.1. Basic usage
9.5.2. Interactivity options
9.5.3. JavaScript API
9.5.4. Reference data
9.6. <rich:inputNumberSlider>
9.6.1. Basic usage
9.6.2. Interactivity options
9.6.3. JavaScript API
9.6.4. Reference data
9.7. <rich:inputNumberSpinner>
9.7.1. Basic usage
9.7.2. Interactivity options
9.7.3. JavaScript API
9.7.4. Reference data
9.8. <rich:select>
9.8.1. Basic usage
9.8.2. Advanced options
9.8.3. Using manual input
9.8.4. JavaScript API
9.8.5. Reference data

This chapter details rich components for user input and interaction.

The <rich:autocomplete> component is an auto-completing input-box with built-in Ajax capabilities. It supports client-side suggestions, browser-like selection, and customization of the look and feel.

Figure 9.1. <rich:autocomplete>


The <rich:autocomplete> component uses the JavaScript startsWith() method to create the list of suggestions. The filtering is performed on the client side. Alternatively, use the clientFilter attribute to specify a custom filtering function. The custom function must accept two parameters: the subString parameter is the filtering value as typed into the text box by the user, and the value parameter is an item in the list of suggestions against which the subString must be checked. Each item is iterated through and passed to the function as the value parameter. The custom function must return a boolean value indicating whether the passed item meets the conditions of the filter, and the suggestion list is constructed from successful items.


The <rich:calendar> component allows the user to enter a date and time through an in-line or pop-up calendar. The pop-up calendar can navigate through months and years, and its look and feel can be highly customized.

Figure 9.2. <rich:calendar>


Instead of using a data model, the <rich:calendar> component can be customized on the client-side using JavaScript. Use the dayClassFunction attribute to reference the function that determines the CSS style class for each day cell. Use the dayDisableFunction to reference the function that enables or disables a day cell. Example 9.4, “Client-side customization” demonstrates how client-side customization can be used to style different days in a calendar.


The <rich:fileUpload> component allows the user to upload files to a server. It features multiple uploads, progress bars, restrictions on file types, and restrictions on sizes to be uploaded.

The <rich:inplaceInput> component allows information to be entered in-line in blocks of text, improving readability of the text. Multiple input regions can be navigated with keyboard navigation. The component has three functional states: the view state, where the component displays its initial setting, such as "click to edit"; the edit state, where the user can input text; and the "changed" state, where the new value for the component has been confirmed but can be edited again if required.

The <rich:inplaceSelect> component is similar to the <rich:inplaceInput> component, except that the <rich:inplaceSelect> component uses a drop-down selection box to enter text instead of a regular text field. Changes can be rendered either in-line or for the whole block, and inputs can be focused with keyboard navigation. The component has three functional states: the view state, where the component displays its initial setting, such as "click to edit"; the edit state, where the user can select a value from a drop-down list; and the "changed" state, where the new value for the component has been confirmed but can be edited again if required.

Figure 9.3. <rich:inplaceSelect>


The <rich:inputNumberSlider> component provides a slider for changing numerical values. Optional features include control arrows to step through the values, a tool-tip to display the value while sliding, and a text field for typing the numerical value which can then be validated against the slider's range.

Figure 9.4. <rich:inputNumberSlider>


The <rich:inputNumberSpinner> component is a single-line input field with buttons to increase and decrease a numerical value. The value can be changed using the corresponding directional keys on a keyboard, or by typing into the field.

Figure 9.5. <rich:inputNumberSpinner>


The <rich:select> component provides a drop-down list box for selecting a single value from multiple options. The component supports keyboard navigation and can optionally accept typed input. The <rich:select> component functions similarly to the JavaServer Faces <h:selectOneMenu> component.

Figure 9.6. <rich:select>