The <rich:panelMenuItem> component is used to define a single item inside popup list.
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 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 | if "true", submits ONLY one field/link, instead of all form controls |
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. false is default. |
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 |
iconClass | Class to be applied to icon element. |
iconDisabled | Path to the icon to be displayed for the disabled item state |
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 (ajax,server(Default),none) |
name | 'selectedChild' attribute of PanelMenu refers to group/item with the same name |
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.361. 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 |
To create the simplest variant on a page use the following syntax:
Example:
...
<rich:panelMenu>
...
<rich:panelMenuItem value="Item1"/>
...
</rich:panelMenu>
...
Example:
import org.richfaces.component.html.HtmlPanelMenuItem;
...
HtmlPanelMenuItem myPanelMenuItem = new HtmlPanelMenuItem();
...
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:
Here is an example:
Example:
...
<rich:panelMenu>
...
<rich:panelMenuItem ="Item 1.1" icon="chevronUp" />
...
</rich:panelMenu>
...
As the result the picture is shown below:
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.
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
Table 6.362. 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.363. Skin parameter redefinition for a disabled item
Parameter for disabled item | CSS properties |
---|---|
tabDisabledTextColor | color |
On the screenshot there are classes names that define styles for component elements.
Table 6.364. 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.365. 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.366. 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 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.
Some additional information about usage of component can be found here.