6.70.  < rich:panelMenuItem >

6.70.1. Description

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

<rich:panelMenuItem> component

Figure 6.183.  <rich:panelMenuItem> component


6.70.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.360. rich : panelMenuItem attributes

Attribute NameDescription
actionMethodBinding 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
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
disabledIf true sets state of the item to disabled state. false is default.
disabledClassClass to be applied to disabled items.
disabledStyleCSS style rules to be applied to disabled items.
eventsQueueName 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.)
focusid of element to set focus after request completed on client side
hoverClassClass to be applied to hovered items.
hoverStyleCSS style rules to be applied to hovered items.
iconPath to the icon or the default one name to be displayed for the enabled item state
iconClassClass to be applied to icon element.
iconDisabledPath to the icon to be displayed for the disabled item state
iconStyleCSS style rules to be applied
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute 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
immediateTrue 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
labelDefines representation text for menuItem.
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
modeSet the submission mode (ajax,server(Default),none)
name'selectedChild' attribute of PanelMenu refers to group/item with the same name
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
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
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
processId['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
renderedIf "false", this component is not rendered
requestDelayAttribute 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
reRenderId['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
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
targetTarget frame for action to execute.
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
valueThe current value for this component

Table 6.361. Component identification parameters

NameValue
component-typeorg.richfaces.PanelMenuItem
component-classorg.richfaces.component.html.HtmlPanelMenuItem
component-familyorg.richfaces.PanelMenuItem
renderer-typeorg.richfaces.PanelMenuItemRenderer
tag-classorg.richfaces.taglib.PanelMenuItemTag

6.70.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.70.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlPanelMenuItem;  
...
HtmlPanelMenuItem myPanelMenuItem = new HtmlPanelMenuItem();
...

6.70.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:

Default icons

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

Using an "icon" attribute

Figure 6.185. 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.70.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.70.7.  Skin Parameters Redefinition

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

Skin parametersCSS properties
generalFamilyFontfont-family
generalWeightFontfont-weight
generalSizeFontfont-size
generalTextColorcolor
panelBorderColorborder-top-color

Table 6.363. Skin parameter redefinition for a disabled item

Parameter for disabled itemCSS properties
tabDisabledTextColorcolor

6.70.8. Definition of Custom Style Classes

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

Classes names

Figure 6.186. Classes names


Classes names

Figure 6.187. Classes names


Table 6.364. Classes names that define the first level items

Class nameDescription
rich-pmenu-top-itemDefines styles for a top panel menu item
rich-pmenu-top-item-iconDefines styles for a top panel menu item icon
rich-pmenu-top-item-labelDefines styles for a top panel menu item label

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

Class nameDescription
rich-pmenu-itemDefines styles for a panel menu item
rich-pmenu-item-iconDefines styles for a panel menu item icon
rich-pmenu-item-labelDefines styles for a panel menu item label

Table 6.366. Classes names that define items state

Class nameDescription
rich-pmenu-item-selectedDefines styles for a panel menu selected item
rich-pmenu-disabled-elementDefines styles for a disabled panel menu item
rich-pmenu-hovered-elementDefines 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 and define necessary properties in them.

To change styles of particular <rich:panelMenuItem> components, define your own style classes in the corresponding <rich:panelMenuItem> attributes.

6.70.9. Relevant resources links

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