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. Reference data
9.2. <rich:calendar>
9.2.1. Basic usage
9.2.2. Using a data model
9.2.3. Client-side customization
9.2.4. Behavior and appearance
9.2.5. Time of day
9.2.6. Localization and formatting
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. Reference data
9.5. <rich:inplaceSelect>
9.5.1. Basic usage
9.5.2. Interactivity options
9.5.3. Reference data
9.6. <rich:inputNumberSlider>
9.6.1. Basic usage
9.6.2. Interactivity options
9.6.3. Reference data
9.7. <rich:inputNumberSpinner>
9.7.1. Basic usage
9.7.2. Interactivity options
9.7.3. 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. Reference data

Documentation in development

Some concepts covered in this chapter may refer to the previous version of Richfaces, version 3.3.3. This chapter is scheduled for review to ensure all information is up to date.

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>


The <rich:calendar> component is presented as a pop-up by default, appearing as a text field with a button to expand the full pop-up calendar. To render the calendar in-line on the page instead, set popup="false. This displays the full calendar without the text field or display button.

To add keyboard support for manual input, set enableManualInput="true". To disable the calendar from any user input, set disabled="true".

To change the appearance of the display button from the standard calendar icon, use the buttonIcon and buttonDisabledIcon attributes to replace the icon with a specified file. Alternatively, use the buttonLabel attribute to display text on the button without an icon. If buttonLabel is specified then both the buttonIcon and buttonDisabledIcon attributes are ignored. To hide the text field box, set showInput="false".

The calendar features a Today button for locating today's date on the calendar. This can be set to three different values using the todayControlMode attribute:

To make the entire calendar read-only, set readonly="true". This allows months and years to be browsed through with the arrow controls, but dates and times cannot be selected.

The styling and appearance of the calendar can be fully customized using facets. The header and footer facets define the calendar's header and footer. The optionalHeader and optionalFooter facets define the calendar's optional header and optional footer. The weekNumber facet controls the appearance of the week numbers, and the weekDay facet controls the appearance of the individual day cells on the calendar. Figure 9.3, “Facet elements” shows some of the elements available for customization through the various facets.

Figure 9.3. Facet elements


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.4. <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.5. <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.6. <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.7. <rich:select>