JBoss.org Community Documentation

- Prev
- Next

## 6.72. < rich:pickList >

### 6.72.1. Description

The <rich:pickList> component is used for moving selected item(s) from one list into another.

Figure 6.217. <rich:pickList> component

### 6.72.2. Key Features

- Multiple selection of list items

- Keyboard support

- Supports standard JSF internationalization

- Highly customizable look and feel

Table 6.372. rich : pickList attributes

Attribute Name | Description
--- | ---
binding | The attribute takes a value-binding expression for a component property of a backing bean
controlClass | CSS class for a list
converter | Id of Converter to be used or reference to a Converter
converterMessage | A ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter
copyAllControlLabel | Defines a label for a copyAll control
copyControlLabel | Defines a label for a copy control
disabled | If "true", disable this component on page.
disabledStyle | CSS style rules to be applied to disabled controls
disabledStyleClass | The disabledStyleClass for disabled controls
enabledStyle | CSS style rules to be applied to enabled controls
enabledStyleClass | The enabledStyleClass for enabled controls
id | Every component may have a unique id that is automatically created if omitted
immediate | A 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
listClass | CSS class for a list
listsHeight | Defines height of the list
moveControlsVerticalAlign | Customizes vertically a position of move/copy controls relatively to lists. Default value is "center".
onblur | HTML: script expression; the element lost the focus
onclick | HTML: a script expression; a pointer button is clicked
ondblclick | HTML: a script expression; a pointer button is double-clicked
onfocus | HTML: script expression; the element got the focus
onkeydown | HTML: a script expression; a key is pressed down
onkeypress | HTML: a script expression; a key is pressed and released
onkeyup | HTML: a script expression; a key is released
onlistchanged | A JavaScript event handler called on a list change operation
onmousedown | HTML: script expression; a pointer button is pressed down
onmousemove | HTML: a script expression; a pointer is moved within
onmouseout | HTML: a script expression; a pointer is moved away
onmouseover | HTML: a script expression; a pointer is moved onto
onmouseup | HTML: script expression; a pointer button is released
removeAllControlLabel | Defines a label for a removeAll control
removeControlLabel | Defines a label for a remove control
rendered | If "false", this component is not rendered
required | If "true", this component is checked for non-empty input
requiredMessage | A 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
showButtonsLabel | Shows a label for a button
sourceListWidth | Defines width of a source list
style | CSS style(s) is/are to be applied when this component is rendered
styleClass | Corresponds to the HTML class attribute
switchByClick | If "true", dragging between lists realized by click
targetListWidth | Defines width of a target list
title | Advisory title information about markup elements generated for this component
validator | MethodBinding pointing at a method that is called during Process Validations phase of the request processing lifecycle, to validate the current value of this component
validatorMessage | A ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator
value | The current value of this component
valueChangeListener | Listener for value changes

Table 6.373. Component identification parameters

Name | Value
--- | ---
component-type | org.richfaces.PickList
component-class | org.richfaces.component.html.HtmlPickList
component-family | org.richfaces.PickList
renderer-type | org.richfaces.PickListRenderer
tag-class | org.richfaces.taglib.PickListTag

### 6.72.3. Creating the Component with a Page Tag

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

Example:

    ...

    <rich:pickList value="#{pickBean.targetValues}">

            <f:selectItem itemValue="Bentley" itemLabel="Bentley"/>

            <f:selectItems value="#{pickBean.sourceValues}"/>

    </rich:pickList>

    ...

### 6.72.4. Creating the Component Dynamically Using Java

Example:

    import org.richfaces.component.html.HtmlPickList;

    ...

    HtmlPickList myPickList = new HtmlPickList();

    ...

### 6.72.5. Details of Usage

The <rich:pickList> component consists of

- 2 item lists. Every item has three different representations: common, selected, active. Combination of these states is possible.

- Move controls set is a set of controls, which performs moving items between lists.

The "value" attribute is the initial value of this component.

The <f:selectItem /> or <f:selectItems /> facets are used to define the values of a source list.

Example:

    ...

    <rich:pickList value="#{pickBean.listValues}">

            <f:selectItem itemValue="Bentley" itemLabel="Bentley"/>

            <f:selectItem itemValue="Audi" itemLabel="Audi"/>

            <f:selectItems value="#{pickBean.sourceList}"/>

    </rich:pickList>

    ...

The "switchByClick" attribute provides an option to copy and remove items between lists by one click. Default value of this attribute is "false", so you need a double click to copy, remove items from one list to another.

Lables of the move controls can be defined with "copyAllControlLabel" , "copyControlLabel" , "removeControlLabel" , "removeAllControlLabel" attributes.

Example:

    ...

    <rich:pickList copyAllControlLabel = "#{pickBean.copyAllLabel}" copyControlLabel = "#{pickBean.copyLabel}" removeControlLabel = "#{pickBean.removeLabel}"

    removeAllControlLabel ="#{pickBean.removeAllLabel}" value="#{pickBean.listValues}">

            <f:selectItem itemValue="Bentley" itemLabel="Bentley"/>

            <f:selectItem itemValue="Audi" itemLabel="Audi"/>

            <f:selectItems value="#{pickBean.sourceList}"/>

    </rich:pickList>

    ...

If you don't want to display labels on the buttons you need to set "showButtonsLabel" to "false".

Figure 6.218. Move control buttons without labels

With the help of "moveControlsVerticalAlign" attribute you can align move controls vertically.

The possible value for "moveControlsVerticalAlign" are "top", "bottom" and "center" (default value).

The <rich:pickList> component provides resizing of lists by using such attributes as:

- "listsHeight" defines height of the lists.

- "sourceListWidth" defines width of a source list.

- "targetListWidth" defines width of a target list.

Example:

    ...

    <rich:pickList listsHeight="#{pickBean.listsHeight}" sourceListWidth="#{pickBean.sourceListWidth}" targetListWidth="#{pickBean.targetListWidth}" value="#{pickBean.listValues}">

            <f:selectItem itemValue="Bentley" itemLabel="Bentley"/>

            <f:selectItem itemValue="Audi" itemLabel="Audi"/>

            <f:selectItems value="#{pickBean.sourceList}"/>

    </rich:pickList>

    ...

The <rich:pickList> component allows to use internationalization method to redefine and localize the labels. You could use application resource bundle and define `RICH_PICK_LIST_COPY_ALL_LABEL`, `RICH_PICK_LIST_COPY_LABEL`, `RICH_PICK_LIST_REMOVE_ALL_LABEL`, `RICH_PICK_LIST_REMOVE_LABEL` there.

Table 6.374. Keyboard usage for elements selection

Keys and combinations | Description
--- | ---
CTRL+click | Inverts selection for an item
SHIFT+click | Selects all rows from active one to a clicked row if they differ, else select the active row. All other selections are cleared
CTRL+A | Selects all elements inside the list if some active element is already present in a list
Up, Down arrows | Changes the active and selected elements to the next or previous in a list

### 6.72.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:pickList> components at once:

- Redefine the corresponding skin parameters

- Add to your style sheets style classes used by a <rich:pickList> component

### 6.72.7. Skin Parameters Redefinition

Table 6.375. Skin parameters redefinition for a list

Skin parameters | CSS properties
--- | ---
tableBackgroundColor | background-color

Table 6.376. Skin parameters redefinition for a button

Skin parameters | CSS properties
--- | ---
tabBackgroundColorr | background-color
generalTextColor | color
headerFamilyFont | font-family
headerSizeFont | font-size

Table 6.377. Skin parameters redefinition for a disabled button

Skin parameters | CSS properties
--- | ---
tabBackgroundColor | background-color
tabDisabledTextColor | color
headerFamilyFont | font-family
headerSizeFont | font-size

Table 6.378. Skin parameters redefinition for a pressed button

Skin parameters | CSS properties
--- | ---
tabBackgroundColor | background-color
generalTextColor | color
headerFamilyFont | font-family
headerSizeFont | font-size
tableBorderColor | border-color
tableBorderWidth | border-width

Table 6.379. Skin parameters redefinition for a highlighted button

Skin parameters | CSS properties
--- | ---
tabBackgroundColor | background-color
generalTextColor | color
headerFamilyFont | font-family
headerSizeFon | font-size
selectControlColor | border-color
tableBorderWidth | border-width

Table 6.380. Skin parameters redefinition for a button selection

Skin parameters | CSS properties
--- | ---
generalTextColor | color

Table 6.381. Skin parameters redefinition for a button content

Skin parameters | CSS properties
--- | ---
headerFamilyFont | font-family
headerSizeFont | font-size

Table 6.382. Skin parameters redefinition for a source and target items

Skin parameters | CSS properties
--- | ---
generalBackgroundColor | background-color
tableBorderColor | border-color
tableBorderWidth | border-width

Table 6.383. Skin parameters redefinition for a source and target cell

Skin parameters | CSS properties
--- | ---
generalTextColor | color
generalSizeFont | font-size
generalFamilyFont | font-family

Table 6.384. Skin parameters redefinition for a selected source and target cell

Skin parameters | CSS properties
--- | ---
generalTextColor | color
generalSizeFont | font-size
generalFamilyFont | font-family

Table 6.385. Skin parameters redefinition for an active source and target cell

Skin parameters | CSS properties
--- | ---
generalSizeFont | font-size
generalFamilyFont | font-family
generalTextColor | border-top-color
generalTextColor | border-bottom-color

Table 6.386. Skin parameters redefinition for a selected source and target row

Skin parameters | CSS properties
--- | ---
additionalBackgroundColor | background-color

Table 6.387. Skin parameters redefinition for a controls

Skin parameters | CSS properties
--- | ---
tableBorderColor | border-color

### 6.72.8. Definition of Custom Style Classes

The following pictures illustrate how CSS classes define styles for component elements.

Figure 6.219. Classes names

Figure 6.220. Classes names

Table 6.388. Classes names that define a list representation

Class name | Description
--- | ---
rich-picklist-list | Defines styles for a wrapper <table> element of a pickList

Table 6.389. Classes names that define a source and target items representation

Class name | Description
--- | ---
rich-picklist-source-items | Defines styles for an item in a source list
rich-picklist-target-items | Defines styles for an item in a target list

Table 6.390. Classes names that define a source cell representation

Class name | Description
--- | ---
rich-picklist-source-cell | Defines styles for a cell in a source list
rich-picklist-source-cell-selected | Defines styles for a selected cell in a source list
rich-picklist-source-cell-active | Defines styles for an active cell in a source list

Table 6.391. Classes names that define a target cell representation

Class name | Description
--- | ---
rich-picklist-target-cell | Defines styles for a cell in a source list
rich-picklist-target-cell-selected | Defines styles for a selected cell in a target list
rich-picklist-target-cell-active | Defines styles for an active cell in a target list

Table 6.392. Classes names that define a selected source and target rows representation

Class name | Description
--- | ---
rich-picklist-source-row-selected | Defines styles for a selected row in a source list
rich-picklist-target-row-selected | Defines styles for a selected row in a target list

Table 6.393. Classes names that define a control representation

Class name | Description
--- | ---
rich-picklist-control-disabled | Defines styles for a control in a disabled state
rich-picklist-control-copyall | Defines styles for a "copyAll" control
rich-picklist-control-copy | Defines styles for a "Copy" control
rich-picklist-control-remove | Defines styles for a "Remove" control
rich-picklist-control-removeall | Defines styles for a "removeAll" control

Table 6.394. Classes names that define a button representation

Class name | Description
--- | ---
rich-list-picklist-button | Defines styles for a button
rich-list-picklist-button-disabled | Defines styles for a disabled button
rich-list-picklist-button-press | Defines styles for a pressed button
rich-list-picklist-button-light | Defines styles for a button highlight
rich-list-picklist-button-selection | Defines styles for a button selection
rich-list-picklist-button-content | Defines styles for a button content

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

Example:

    ...

    .rich-picklist-list{

            background-color:#ecf4fe;

    }

    ...

This is a result:

Figure 6.221. Redefinition styles with predefined classes

In the example the background color for lists is changed.

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

Example:

    ...

    .myClass{

            font-weight:bold;

    }

    ...

The "styleClass" attribute for <rich:pickList> is defined as it's shown in the example below:

Example:

    <rich:pickList ... styleClass="myClass"/>

This is a result:

Figure 6.222. Redefinition styles with own classes and styleClass attributes

As it could be seen on the picture above, the font style for buttons is changed.

### 6.72.9. Relevant Resources Links

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

- Prev6.71. < rich:panelMenuItem >
- Top of page
- Front page
- Next6.73. < rich:progressBar >