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.8.4.  < rich:menuItem > available since 3.0.0

The <rich:menuItem> component is used for the definition of a single item inside a pop-up list.

This component can be used not only within <rich:dropDownMenu> and <rich:contextMenu> , but also it can used as a standalone component. For example, you can use it as nested component of the <rich:toolBar> .


Table 6.168. rich : menuItem attributes

Attribute Name Description
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
ajaxSingleLimits JSF tree processing (decoding, conversion, validation and model updating) only to a component that sends the request. Boolean
binding JSF: The 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
disabledHTML: If "true" sets state of the item to disabled state. Default value is "false".
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 an element to set focus after request is completed on client side
iconPath to the icon to be displayed for the enabled item state
iconClassAssigns one or more space-separated CSS class names to the component icon element
iconDisabledPath to the icon to be displayed for the disabled item state.
iconStyleCSS style rules to be applied to the component icon element
id JSF: Every 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
labelClassAssigns one or more space-separated CSS class names to the component label element
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
onbeforedomupdateThe client-side script method to be called before DOM is updated
onclick DHTML: The client-side script method to be called when the element is clicked
oncompleteThe client-side script method to be called after the request is completed
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
onselectThe client-side script method to be called when a menu item is selected
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
rendered JSF: If "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
selectClassAssigns one or more space-separated CSS class names to the selected item
selectStyleCSS style rules to be applied to the selected item
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
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.
submitModeSets the submission mode. Possible values are "ajax", "server", "none". Default value is "server".
targetHTML: Name of a frame where the resource retrieved via this hyperlink is to be displayed
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
value JSF: The current value for this component

Table 6.169. Component identification parameters

NameValue
component-typeorg.richfaces.MenuItem
component-classorg.richfaces.component.html.HtmlMenuItem
component-familyorg.richfaces.DropDownMenu
renderer-typeorg.richfaces.MenuItemRenderer
tag-classorg.richfaces.taglib.MenuItemTag

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

Example:


...
<rich:dropDownMenu>
        ...
       <rich:menuItem value="Active"/>
        ...
<rich:dropDownMenu>
...

Example:

import org.richfaces.component.html.HtmlMenuItem;   

...
HtmlMenuItem myMenuItem = new HtmlMenuItem();
...

The "value" attribute defines the text representation for an item element.

There are two icon-related attributes. The "icon" attribute defines an icon. The "iconDisabled" attribute defines an icon for a disabled item. 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 content is shown as an icon. It 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 <rich:menuItem> "submitMode" attribute can be set to three possible parameters:

Regular form submission request is used.

Ajax submission is used for switching.

The "action" and "actionListener" item's attributes are ignored. Menu items don' fire any submits themselves. The behavior is fully defined by the components nested into items.

For example, you can put any content into an item, but, in this case, you should set the "submitMode" attribute as "none" .

Here is an example:


...
<rich:dropDownMenu>
        ...
       <rich:menuItem submitMode="none">
                <h:outputLink value="www.jboss.org"/>
        </rich:menuItem>
        ...
<rich:dropDownMenu>
...

You can use the "disabled" attribute to set the item state.

Here is an example:


...
<rich:dropDownMenu>
        <rich:menuItem value="Disable" disabled="true"/>
<rich:dropDownMenu>
...

Information about the "process" attribute usage you can find RichFaces Developer Guide section about "process" attribute .


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:menuItem> components at once:





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




In order to redefine styles for all <rich:menuItem> 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-menu-item-disabled{
        
font-style: italic;
}
...

This is a result:


In the example a disabled item font style was changed.

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

Example:


...
.myClass{
        
border-color: #bed6f8;
        
background-color: #ffffff;
}
...

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

Example:


<rich:menuItem ... selectStyle="myClass">

This is a result:


As it could be seen on the picture above, the background color and border color for selected item were changed.

On the component LiveDemo page you can see the example of <rich:menuItem> usage and sources for the given example.