14.3. Menu sub-components

The <rich:menuItem>, <rich:menuGroup>, and <rich:menuSeparator> components are used to construct menus for the <rich:dropDownMenu> component. Refer to Section 14.1, “<rich:dropDownMenu> for more details on the <rich:dropDownMenu> component.

14.3.1. <rich:menuItem>

The <rich:menuItem> component represents a single item in a menu control. The <rich:menuItem> component can be also be used as a seperate component without a parent menu component, such as on a toolbar.

14.3.1.1. Basic usage

The <rich:menuItem> component requires the label attribute for basic usage. The label attribute is the text label for the menu item.

14.3.1.2. Appearance

Icons can be added to menu items through the use of two icon attributes. The icon attribute specifies the normal icon, while the iconDisabled attribute specifies the icon for a disabled item.
Alternatively, define facets with the names icon and iconDisabled to set the icons. If facets are defined, the icon and iconDisabled attributes are ignored. Using facets for icons allows more complex usage; example shows a checkbox being used in place of an icon.

Example 14.1. Icon facets

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

14.3.1.3. Submission modes

Use the submitMode attribute to determine how the menu item requests are submitted:
  • server, the default setting, submits the form normally and completely refreshes the page.
  • ajax performs an Ajax form submission, and re-renders elements specified with the render attribute.
  • client causes the action and actionListener items to be ignored, and the behavior is fully defined by the nested components instead of responses from submissions.

14.3.1.4. JavaScript API

The <rich:menuItem> component can be controlled through the JavaScript API. The JavaScript API provides the following functions:
activate()
Activate the menu item as though it were selected.

14.3.1.5. Reference data

  • component-type: org.richfaces.MenuItem
  • component-class: org.richfaces.component.UIMenuItem
  • component-family: org.richfaces.DropDownMenu
  • renderer-type: org.richfaces.MenuItemRenderer

14.3.2. <rich:menuGroup>

The <rich:menuGroup> component represents an expandable sub-menu in a menu control. The <rich:menuGroup> component can contain a number of <rich:menuItem> components, or further nested <rich:menuGroup> components.

14.3.2.1. Basic usage

The <rich:menuGroup> component requires the label attribute for basic usage. The label attribute is the text label for the menu item. Alternatively, use the label facet to define content for the label.
Additionally, the <rich:menuGroup> component must contain child <rich:menuItem> components or <rich:menuGroup> components.

14.3.2.2. Appearance

Icons can be added to menu groups through the use of two icon attributes. The icon attribute specifies the normal icon, while the iconDisabled attribute specifies the icon for a disabled group.
The <rich:menuGroup> component can be positioned using the jointPoint and direction attributes, the same as the parent menu control. For details on the jointPoint and direction attributes, refer to Section 14.1.3, “Appearance”.

14.3.2.3. JavaScript API

The <rich:menuGroup> component can be controlled through the JavaScript API. The JavaScript API provides the following functions:
show()
Show the menu group.
hide()
Hide the menu group.

14.3.2.4. Reference data

  • component-type: org.richfaces.MenuGroup
  • component-class: org.richfaces.component.UIMenuGroup
  • component-family: org.richfaces.DropDownMenu
  • renderer-type: org.richfaces.MenuGroupRenderer

14.3.3. <rich:menuSeparator>

The <rich:menuSeparator> component represents a separating divider in a menu control.

14.3.3.1. Basic usage

The <rich:menuSeparator> component does not require any attributes for basic usage. Add it as a child to a menu component to separator menu items and menu groups.

14.3.3.2. Reference data

  • component-type: org.richfaces.MenuSeparator
  • component-class: org.richfaces.component.UIMenuSeparator
  • component-family: org.richfaces.DropDownMenu
  • renderer-type: org.richfaces.MenuSeparatorRenderer