Create new RichFaces Documentation Jira issue

This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.orgCommunity Documentation

6.12.3.  < rich:pickList > available since 3.2.0

Table 6.530. rich : pickList attributes

Attribute Name Description
binding JSF: The attribute takes a value-binding expression for a component property of a backing bean
controlClassAssigns one or more space-separated CSS class names to the component controls
converter JSF: Id 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 "Copy all" control
copyAllTitleHTML: alt for a "Copy all" button
copyAllVisibleIf "false", the 'Copy All' control will not be displayed. Even if this value is "true", the 'Copy All' control will not be displayed if the "fastMoveControlsVisible" attribute is "false". Default value is "true".
copyControlLabelDefines a label for a "Copy" control
copyTitleHTML: alt for a "Copy" button
copyVisibleIf "false", the 'Copy' control will not be displayed. Even if this value is "true", the 'Copy' control will not be displayed if the "moveControlsVisible" attribute is "false". Default value is "true".
disabledHTML: If "true", disable this component on page.
disabledStyleCSS style rules to be applied to the component disabled controls
disabledStyleClassAssigns one or more space-separated CSS class names to the component disabled controls
enabledStyleCSS style rules to be applied to the component enabled controls
enabledStyleClassAssigns one or more space-separated CSS class names to the component enabled controls
fastMoveControlsVisibleIf "false", 'Copy All' and 'Remove All' controls aren't displayed. Even if this value is "true", the 'Copy All' and 'Remove All' controls will not be displayed if the "copyAllVisible" and "removeAllVisible" attribute values are "false". Default value is "true".
id JSF: Every 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
labelA localized user presentable name for this component.
listClassAssigns one or more space-separated CSS class names to the component lists
listsHeightDefines height of the list. Default value is "140px"
moveControlsVerticalAlignCustomizes vertically a position of move/copy controls relatively to lists. Default value is "center".
moveControlsVisibleIf "false", 'Copy' and 'Remove' controls aren't displayed. Even if this value is "true", the 'Copy' and 'Remove' controls will not be displayed if the "copyVisible" and "removeVisible" attribute values are "false". Default value is "true".
onblur DHTML: The client-side script method to be called when the component loses the focus
onclick DHTML: The client-side script method to be called when the element is clicked
ondblclick DHTML: The client-side script method to be called when the element is double-clicked
onfocus DHTML: The client-side script method to be called when the component gets the focus
onkeydown DHTML: The client-side script method to be called when a key is pressed down over the element
onkeypress DHTML: The client-side script method to be called when a key is pressed over the element and released
onkeyup DHTML: The client-side script method to be called when a key is released
onlistchangeThe client-side script method to be called when the list is changed
onlistchangedThe client-side script method to be called before the list is changed
onmousedown DHTML: The client-side script method to be called when a mouse button is pressed down over the element
onmousemove DHTML: The client-side script method to be called when a pointer is moved within the element
onmouseout DHTML: The client-side script method to be called when a pointer is moved away from the element
onmouseover DHTML: The client-side script method to be called when a pointer is moved onto the element
onmouseup DHTML: The client-side script method to be called when a mouse button is released
removeAllControlLabelDefines a label for a "Remove all" control
removeAllTitleHTML: alt for a "Remove" all button
removeAllVisibleIf "false", the 'Remove All' control will not be displayed. Even if this value is "true", the 'Remove All' control will not be displayed if the "fastMoveControlsVisible" attribute is "false". Default value is "true".
removeControlLabelDefines a label for a "Remove" control
removeTitleHTML: alt for a "Remove" button
removeVisibleIf "false", the 'Remove' control will not be displayed. Even if this value is "true", the 'Remove' control will not be displayed if the "moveControlsVisible" attribute is "false". Default value is "true".
rendered JSF: If "false", this component is not rendered
required JSF: If "true", this component is checked for non-empty input
requiredMessageA ValueExpression enabled attribute which defines text of validation message to show, if a required field is missing
showButtonsLabelShows a label for a button. Default value is "true"
sourceListWidthDefines width of a source list. Default value is "140px"
styleHTML: CSS style rules to be applied to the component
styleClass JSF: Assigns one or more CSS class names to the component. Corresponds to the HTML "class" attribute.
switchByClickIf "true", items can be moved between the lists by clicking on them. Default value is "false".
switchByDblClickIf "true", items can be moved between the lists by double-clicking on them. Default value is "true".
targetListWidthDefines width of a target list. Default value is "140px"
titleHTML: Advisory title information about markup elements generated for this component
validator JSF: 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
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
value JSF: The current value of this component
valueChangeListener JSF: Listener for value changes


The <rich:pickList> component consists of

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


Alternative to the given attributes are the following facets: "copyAllControl" , "removeAllControl" , "copyControl" , "removeControl" , "copyAllControlDisabled" , "removeAllControlDisabled" , "copyControlDisabled" , "removeControlDisabled" , "caption" .

It is an example of usage of the facets and it is identical to the previous example.


...
<rich:pickList value="#{pickBean.listValues}">
    <f:facet name="copyAllControl">
        <h:commandButton value="#{pickBean.copyAllLabel}" />
    </f:facet>
    <f:facet name="copyControl">
        <h:commandButton value="#{pickBean.copyLabel}" />
    </f:facet>
    <f:facet name="removeControl">
        <h:commandButton value="#{pickBean.removeLabel}" />
    </f:facet>
    <f:facet name="removeAllControl">
        <h:commandButton value="#{pickBean.removeAllLabel}" />
    </f:facet>
    <f:selectItem itemValue="Bentley" itemLabel="Bentley"/>
    <f:selectItem itemValue="Audi" itemLabel="Audi"/>
    <f:selectItems value="#{pickBean.sourceList}"/>
</rich:pickList>
...

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.















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









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:


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:


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

On RichFaces LiveDemo page you can see an example of <rich:pickList> usage and sources for the given example.