6.46.  < rich:menuGroup >

6.46.1. Description

The <rich:menuGroup> component is used to define an expandable group of items inside a pop-up list or another group.

<rich:menuGroup> component

Figure 6.81.  <rich:menuGroup> component


6.46.2. Key Features

  • Highly customizable look-and-feel

  • Grouping of any menu's items

  • Pop-up appearance event customization

  • Support for disabling

  • Smart user-defined positioning

Table 6.170. rich : menuGroup attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
converterId of Converter to be used or reference to a Converter
directionDefines direction of the popup sublist to appear (right, left, auto(Default), left-down, left-up, right-down, right-up)
disabledIf "true" sets state of the item to disabled state. "false" is default
eventDefines the event on the representation element that triggers the menu's appearance
iconPath to the icon 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
iconFolderPath to the folder icon to be displayed for the enabled item state
iconFolderDisabledPath to the folder icon to be displayed for the enabled item state
iconStyleCSS style rules to be applied to icon element
idEvery component may have a unique id that is automatically created if omitted
labelClassClass to be applied to label element
oncloseHTML: script expression; group was closed
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
onopenHTML: script expression; group was opened
renderedIf "false", this component is not rendered
selectClassClass to be applied to selected items
selectStyleCSS style rules to be applied to selected items
showDelayDelay between event and menu showing
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
valueDefines representation text for menuItem

Table 6.171. Component identification parameters

NameValue
component-typeorg.richfaces.MenuGroup
component-classorg.richfaces.component.html.HtmlMenuGroup
component-familyorg.richfaces.DropDownMenu
renderer-typeorg.richfaces.MenuGroupRenderer
tag-classorg.richfaces.taglib.MenuGroupTag

6.46.3. Creating the Component with a Page Tag

Here is a simple example as it could be used on a page:

Example:


...
    <rich:dropDownMenu value="Active">
        ...
        <rich:menuGroup value="Active">
            <!--Nested menu components-->
        </rich:menuGroup>
        ...
    </rich:dropDownMenu >
...

6.46.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlMenuGroup;  
...
HtmlMenuGroup myMenuGroup = new HtmlMenuGroup();
...

6.46.5. Details of Usage

The "value" attribute defines the text representation of a group element in the page.

The "icon" attribute defines an icon for the component. The "iconDisabled" attribute defines an icon for when the group is disabled. Also you can use the "icon" and "iconDisabled" facets. If the facets are defined, the corresponding "icon" and "iconDisabled" attributes are ignored and the facets' contents are used as icons. This could be used for an item check box implementation.

Here is an example:


...
    <f:facet name="icon">
        <h:selectBooleanCheckbox value="#{bean.property}"/>
    </f:facet>
...

The "iconFolder" and "iconFolderDisabled" attributes are defined for using icons as folder icons. The "iconFolder" and "iconFolderDisabled" facets use their contents as folder icon representations in place of the attribute values.

The "direction" attribute is used to define which way to display the menu as shown in the example below:

Possible values are:

  • left - down - a submenu is attached to the left side of the menu and is dropping down

  • left - up - a submenu is attached to the left side of the menu and is dropping up

  • right - down - a submenu is attached to the right side of the menu and is dropping down

  • right - up - a submenu is attached to the right side of the menu and is dropping up

  • auto - smart positioning activation

By default, the "direction" attribute is set to "auto" .

Here is an example:


...
        <rich:menuGroup value="Save As..." direction="left-down">
                <rich:menuItem   submitMode="ajax" value="Text File"  action="#{ddmenu.doSaveText}"/>
                <rich:menuItem   submitMode="ajax" value="PDF File"  action="#{ddmenu.doSavePDF}"/>
        </rich:menuGroup>
...

This would be the result:

Using the "direction" attribute

Figure 6.82. Using the "direction" attribute


Note:

The <rich:menuGroup> component was designed to be used only for pop-up menu list creation.

6.46.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:menuGroup> components at once:

  • Redefine the corresponding skin parameters

  • Add to your style sheets style classes used by a <rich:menuGroup> component

6.46.7. Skin Parameters Redefinition

Table 6.172. Skin parameters redefinition for a group

Skin parametersCSS properties
generalFamilyFontfont-family
generalSizeFontfont-size

Table 6.173. Skin parameters redefinition for a disabled group

Skin parametersCSS properties
tabDisabledTextColorcolor

Table 6.174. Skin parameters redefinition for a label

Skin parametersCSS properties
generalTextColorcolor

6.46.8. Definition of Custom Style Classes

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

Classes names

Figure 6.83. Classes names


Table 6.175. Classes names that define an appearance of group elements

Class nameDescription
rich-menu-groupDefines styles for a wrapper <div> element for a group
rich-menu-item-labelDefines styles for a label of an item
rich-menu-item-iconDefines styles for the left icon of an item
rich-menu-item-folderDefines styles for the right icon of an item

Table 6.176. Classes names that define different states

Class nameDescription
rich-menu-item-label-disabledDefines styles for a label of a disabled item
rich-menu-item-icon-disabledDefines styles for the left icon of a disabled item
rich-menu-item-folder-disabledDefines styles for the right icon of a disabled item
rich-menu-group-hoverDefines styles for a wrapper <div> element of a hover group
rich-menu-item-icon-enabledDefines styles for the left icon of an enabled item
rich-menu-item-icon-selectedDefines styles for the left icon of a selected item

In order to redefine styles for all <rich:menuGroup> 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:menuGroup> components, define your own style classes in the corresponding <rich:menuGroup> attributes.

6.46.9. Relevant Resources Links

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