6.71.  < rich:pickList >

6.71.1. Description

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

<rich:pickList> component

Figure 6.188.  <rich:pickList> component


6.71.2. Key Features

  • Multiple selection of list items

  • Keyboard support

  • Supports standard JSF internationalization

  • Highly customizable look and feel

Table 6.367. rich : pickList attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
controlClassCSS class for a list
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
copyAllControlLabelDefines a label for a copyAll control
copyControlLabelDefines a label for a copy control
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
disableddisabled
disabledStyleCSS style rules to be applied to disabled controls
disabledStyleClassThe disabledStyleClass for disabled controls
enabledStyleCSS style rules to be applied to enabled controls
enabledStyleClassThe enabledStyleClass for enabled controls
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
langCode describing the language used in the generated markup for this component
listClassCSS class for a list
listsHeightDefines height of the list
moveControlsVerticalAlignCustomizes vertically a position of move/copy controls relatively to lists
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
onfocusHTML: script expression; the element got the focus
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onlistchangedA JavaScript event handler called on a list change operation
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
removeAllControlLabelDefines a label for a removeAll control
removeControlLabelDefines a label for a remove control
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
showButtonsLabelShows a label for a button
sizeThis attribute tells the user agent the initial width of the control. The width is given in pixels except when type attribute has the value "text" or "password". In that case, its value refers to the (integer) number of characters
sourceListWidthDefines width of a source list
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
switchByClickIf "true", dragging between lists realized by click
targetListWidthDefines width of a target list
titleAdvisory title information about markup elements generated for this component
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.368. Component identification parameters

NameValue
component-typeorg.richfaces.PickList
component-classorg.richfaces.component.html.HtmlPickList
component-familyorg.richfaces.PickList
renderer-typeorg.richfaces.PickListRenderer
tag-classorg.richfaces.taglib.PickListTag

6.71.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.71.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlPickList;
... 
HtmlPickList myPickList = new HtmlPickList();
...

6.71.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".

Move control buttons without labels

Figure 6.189. Move control buttons without labels


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

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.369. Keyboard usage for elements selection

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

6.71.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.71.7. Skin Parameters Redefinition

Table 6.370. Skin parameters redefinition for a list

Skin parametersCSS properties
tableBackgroundColorbackground-color

Table 6.371. Skin parameters redefinition for a button

Skin parametersCSS properties
tabBackgroundColorrbackground-color
generalTextColorcolor
headerFamilyFontfont-family
headerSizeFontfont-size

Table 6.372. Skin parameters redefinition for a disabled button

Skin parametersCSS properties
tabBackgroundColorbackground-color
tabDisabledTextColorcolor
headerFamilyFontfont-family
headerSizeFontfont-size

Table 6.373. Skin parameters redefinition for a pressed button

Skin parametersCSS properties
tabBackgroundColorbackground-color
generalTextColorcolor
headerFamilyFontfont-family
headerSizeFontfont-size
tableBorderColorborder-color
tableBorderWidthborder-width

Table 6.374. Skin parameters redefinition for a highlighted button

Skin parametersCSS properties
tabBackgroundColorbackground-color
generalTextColorcolor
headerFamilyFontfont-family
headerSizeFonfont-size
selectControlColorborder-color
tableBorderWidthborder-width

Table 6.375. Skin parameters redefinition for a button selection

Skin parametersCSS properties
generalTextColorcolor

Table 6.376. Skin parameters redefinition for a button content

Skin parametersCSS properties
headerFamilyFontfont-family
headerSizeFontfont-size

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

Skin parametersCSS properties
generalBackgroundColorbackground-color
tableBorderColorborder-color
tableBorderWidthborder-width

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

Skin parametersCSS properties
generalTextColorcolor
generalSizeFontfont-size
generalFamilyFontfont-family

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

Skin parametersCSS properties
generalTextColorcolor
generalSizeFontfont-size
generalFamilyFontfont-family

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

Skin parametersCSS properties
generalSizeFontfont-size
generalFamilyFontfont-family
generalTextColorborder-top-color
generalTextColorborder-bottom-color

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

Skin parametersCSS properties
additionalBackgroundColorbackground-color

Table 6.382. Skin parameters redefinition for a controls

Skin parametersCSS properties
tableBorderColorborder-color

6.71.8. Definition of Custom Style Classes

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

Classes names

Figure 6.190. Classes names


Classes names

Figure 6.191. Classes names


Table 6.383. Classes names that define a list representation

Class nameDescription
rich-picklist-listDefines styles for a wrapper <table> element of a pickList

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

Class nameDescription
rich-picklist-source-itemsDefines styles for an item in a source list
rich-picklist-target-itemsDefines styles for an item in a target list

Table 6.385. Classes names that define a source cell representation

Class nameDescription
rich-picklist-source-cellDefines styles for a cell in a source list
rich-picklist-source-cell-selectedDefines styles for a selected cell in a source list
rich-picklist-source-cell-activeDefines styles for an active cell in a source list

Table 6.386. Classes names that define a target cell representation

Class nameDescription
rich-picklist-target-cellDefines styles for a cell in a source list
rich-picklist-target-cell-selectedDefines styles for a selected cell in a target list
rich-picklist-target-cell-activeDefines styles for an active cell in a target list

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

Class nameDescription
rich-picklist-source-row-selectedDefines styles for a selected row in a source list
rich-picklist-target-row-selectedDefines styles for a selected row in a target list

Table 6.388. Classes names that define a control representation

Class nameDescription
rich-picklist-control-disabledDefines styles for a control in a disabled state
rich-picklist-control-copyallDefines styles for a "copyAll" control
rich-picklist-control-copyDefines styles for a "Copy" control
rich-picklist-control-removeDefines styles for a "Remove" control
rich-picklist-control-removeallDefines styles for a "removeAll" control

Table 6.389. Classes names that define a button representation

Class nameDescription
rich-list-picklist-buttonDefines styles for a button
rich-list-picklist-button-disabledDefines styles for a disabled button
rich-list-picklist-button-pressDefines styles for a pressed button
rich-list-picklist-button-lightDefines styles for a button highlight
rich-list-picklist-button-selectionDefines styles for a button selection
rich-list-picklist-button-contentDefines 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:

Redefinition styles with predefined classes

Figure 6.192. 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:

Redefinition styles with own classes and styleClass attributes

Figure 6.193. 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.71.9. Relevant Resources Links

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