JBoss.org Community Documentation

- Prev
- Next

## 6.75. < rich:panelMenuItem >

### 6.75.1. Description

The <rich:panelMenuItem> component is used to define a single item inside popup list.

Figure 6.221. <rich:panelMenuItem> component

### 6.75.2. Key Features

- Highly customizable look-and-feel

- Different submission modes

- Optionally supports any content inside

- Custom and predefined icons supported

- Support for disabling

Table 6.382. rich : panelMenuItem attributes

Attribute Name | Description
--- | ---
action | MethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListener | MethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingle | boolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
binding | The attribute takes a value-binding expression for a component property of a backing bean
bypassUpdates | If "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
data | Serialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
disabled | If true sets state of the item to disabled state. Default value is "false".
disabledClass | Class to be applied to disabled items.
disabledStyle | CSS style rules to be applied to disabled items.
eventsQueue | Name of requests queue to avoid send next request before complete other from same event. Can be used to reduce number of requests of frequently events (key press, mouse move etc.)
focus | id of element to set focus after request completed on client side
hoverClass | Class to be applied to hovered items.
hoverStyle | CSS style rules to be applied to hovered items.
icon | Path to the icon or the default one name to be displayed for the enabled item state. You can also use predefined icons, setting the attribute to one of these possible values: "triangle", "triangleUp", "triangleDown", "disc", "chevron", "chevronUp", "chevronDown", "grid". Default value is "grid".
iconClass | Class to be applied to icon element.
iconDisabled | Path to the icon to be displayed for the disabled item state. You can also use predefined icons, setting the attribute to one of these possible values: "triangle", "triangleUp", "triangleDown", "disc", "chevron", "chevronUp", "chevronDown", "grid". Default value is "grid".
iconStyle | CSS style rules to be applied
id | Every component may have a unique id that is automatically created if omitted
ignoreDupResponses | Attribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server, but just allows to avoid unnecessary updates on the client side if the response isn't actual now
immediate | True means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
label | Defines representation text for menuItem.
limitToList | If "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
mode | Set the submission mode. Possible values are "ajax", "server", "none". Default value is "none".
name | 'selectedChild' attribute of PanelMenu refers to group/item with the same name. Default value is "getId()".
onbeforedomupdate | JavaScript code for call before DOM has been updated on client side
onclick | HTML: a script expression; a pointer button is clicked
oncomplete | JavaScript code for call after request completed on client side
ondblclick | HTML: a script expression; a pointer button is double-clicked
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
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
process | Id['s] (in format of call UIComponent.findComponent()) of components, processed at the phases 2-5 in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
rendered | If "false", this component is not rendered
requestDelay | Attribute defines the time (in ms.) that the request will be wait in the queue before it is ready to send. When the delay time is over, the request will be sent to the server or removed if the newest 'similar' request is in a queue already
reRender | Id['s] (in format of call UIComponent.findComponent()) of components, rendered in case of AjaxRequest caused by this component. Can be single id, comma-separated list of Id's, or EL Expression with array or Collection
status | ID (in format of call UIComponent.findComponent()) of Request status component
style | CSS style(s) is/are to be applied when this component is rendered
styleClass | Corresponds to the HTML class attribute
target | Target frame for action to execute.
timeout | Response waiting time on a particular request. If a response is not received during this time, the request is aborted
value | The current value for this component

Table 6.383. Component identification parameters

Name | Value
--- | ---
component-type | org.richfaces.PanelMenuItem
component-class | org.richfaces.component.html.HtmlPanelMenuItem
component-family | org.richfaces.PanelMenuItem
renderer-type | org.richfaces.PanelMenuItemRenderer
tag-class | org.richfaces.taglib.PanelMenuItemTag

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

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

Example:

    ...

          <rich:panelMenu>

                 ...

                <rich:panelMenuItem value="Item1"/>

                ...

          </rich:panelMenu>

    ...

### 6.75.4. Creating the Component Dynamically Using Java

Example:

    import org.richfaces.component.html.HtmlPanelMenuItem;

    ...

    HtmlPanelMenuItem myPanelMenuItem = new HtmlPanelMenuItem();

    ...

### 6.75.5. Details of Usage

All attributes except "label" are optional. The "label" attribute defines text to be represented.

The "mode" attribute could be used with three possible parameters:

- `Server` (default)

Regular form submission request is used.

- `Ajax`

Ajax submission is used for switching.

- `None`

"Action" and "actionListener" attributes are ignored. Items don't fire any submits itself. Behavior is fully defined by the components nested into items.

Here is an example for value "none":

Example:

    ...

          <rich:panelMenu>

                ...

                <rich:panelMenuItem submitMode="none" onclick="document.location.href='http://labs.jboss.com/jbossrichfaces/">

                      <h:outputLink value="http://labs.jboss.com/jbossrichfaces/">

                            <h:outputText value="RichFaces Home Page"></h:outputText>

                      </h:outputLink>

                </rich:panelMenuItem>

                ...

          </rich:panelMenu>

    ...

There are two icon-related attributes. The "icon" attribute defines an icon. The "iconDisabled" attribute defines an icon for a disabled item.

Default icons are shown on the picture below:

Figure 6.222. Default icons

Here is an example:

Example:

    ...

          <rich:panelMenu>

                ...

                <rich:panelMenuItem ="Item 1.1" icon="chevronUp" />

                ...

          </rich:panelMenu>

    ...

As the result the picture is shown below:

Figure 6.223. Using an "icon" attribute

It's also possible to define a path to the icon. Simple code is placed below.

    ...

          <rich:panelMenu>

                ...

                <rich:panelMenuItem ="Item 1.1" icon="\images\img1.png" />

                ...

          </rich:panelMenu>

    ...

Information about the "process" attribute usage you can find here.

### 6.75.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:panelMenuItem> components at once:

- Redefine the corresponding skin parameters

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

### 6.75.7. Skin Parameters Redefinition

Table 6.384. Skin parameters redefinition for a table element of the first level item

Skin parameters | CSS properties
--- | ---
generalFamilyFont | font-family
generalWeightFont | font-weight
generalSizeFont | font-size
generalTextColor | color
panelBorderColor | border-top-color

Table 6.385. Skin parameter redefinition for a disabled item

Parameter for disabled item | CSS properties
--- | ---
tabDisabledTextColor | color

### 6.75.8. Definition of Custom Style Classes

On the screenshot there are classes names that define styles for component elements.

Figure 6.224. Classes names

Figure 6.225. Classes names

Table 6.386. Classes names that define the first level items

Class name | Description
--- | ---
rich-pmenu-top-item | Defines styles for a top panel menu item
rich-pmenu-top-item-icon | Defines styles for a top panel menu item icon
rich-pmenu-top-item-label | Defines styles for a top panel menu item label

Table 6.387. Classes names that define the second and lower level items

Class name | Description
--- | ---
rich-pmenu-item | Defines styles for a panel menu item
rich-pmenu-item-icon | Defines styles for a panel menu item icon
rich-pmenu-item-label | Defines styles for a panel menu item label

Table 6.388. Classes names that define items state

Class name | Description
--- | ---
rich-pmenu-item-selected | Defines styles for a panel menu selected item
rich-pmenu-disabled-element | Defines styles for a disabled panel menu item
rich-pmenu-hovered-element | Defines styles for a hovered panel menu item

In order to redefine styles for all <rich:panelMenuItem> 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-pmenu-hovered-element {

      background-color: #ff7800;

    }

    ...

This is a result:

Figure 6.226. Redefinition styles with predefined classes

In the example a hovered element background color was changed.

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

Example:

    ...

    .myClass {

            color: #a0a0a0;

    }

    ...

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

Example:

    <rich:panelMenuItem ... disabledClass="myClass"/>

This is a result:

Figure 6.227. Redefinition styles with own classes and styleClass attributes

As it could be seen on the picture above, the text color for disabled item was changed.

### 6.75.9. Relevant resources links

Some additional information about usage of component can be found here.

- Prev6.74. < rich:panelMenuGroup >
- Top of page
- Front page
- Next6.76. < rich:pickList >