11.2. <rich:accordion>
The
<rich:accordion> is a series of panels stacked on top of each other, each collapsed such that only the header of the panel is showing. When the header of a panel is clicked, it is expanded to show the content of the panel. Clicking on a different header will collapse the previous panel and epand the selected one. Each panel contained in a <rich:accordion> component is a <rich:accordionItem> component.
11.2.1. Basic usage
The
<rich:accordion> component requires no attributes for basic usage. The component can contain any number of <rich:accordionItem> components as children. The headers of the <rich:accordionItem> components control the expanding and collapsing when clicked. Only a single <rich:accordionItem> can be displayed at a time. Refer to Section 11.2.8, “<rich:accordionItem>” for details on the <rich:accordionItem> component.
Note
All
<rich:tabPanel> components should be wrapped in a form element when using either ajax or server mode, as usual for submitting components.
11.2.2. Switching panels
The
activeItem attribute holds the active panel name. This name is a reference to the name identifier of the active child <rich:accordionItem> component.
The switching mode for performing submissions is determined by the
switchType attribute, which can have one of the following three values:
server- The default setting. Activation of a
<rich:accordionItem>component causes the parent<rich:accordion>component to perform a common submission, completely refreshing the page. Only one panel at a time is rendered to the client side. ajax- Activation of a
<rich:accordionItem>component causes the parent<rich:accordion>component to perform an Ajax form submission, and the content of the panel is rendered. Only one panel at a time is rendered to the client side. client- Activation of a
<rich:accordionItem>component causes the parent<rich:accordion>component to perform updates on the client side. All the panels are rendered on the client side during the initial page render. JavaScript changes the styles such that one panel component becomes hidden while the other is shown.
11.2.3. <rich:accordion> client-side events
In addition to the standard Ajax events and HTML events, the
<rich:accordion> component uses the client-side events common to all switchable panels:
- The
itemchangeevent points to the function to perform when the switchable item is changed. - The
beforeitemchangeevent points to the function to perform when before the switchable item is changed.
11.2.4. <rich:accordion> server-side events
The
<rich:accordion> component uses the server-side events common to all switchable panels:
- The
ItemChangeEventevent occurs on the server side when an item is changed through Ajax using theservermode. It can be processed using theItemChangeListenerattribute. Refer to Section 11.6.6, “<rich:itemChangeListener>” for details on the<rich:itemChangeListener>tag.
11.2.5. JavaScript API
The
<rich:accordion> component can be controlled through the JavaScript API. The JavaScript API provides the following functions, which are common to all switchable panels:
getItems()- Return an array of the items contained in the accordion control.
getItemsNames()- Return an array of the names of the items contained in the accordion control.
switchToItem(itemName)- Switch to and display the item identified by the
itemNamestring passed as a parameter. firstItem(),prevItem(),nextItem(),lastItem()- Get the name of the first item, the previous item, the next item, or the last item.
11.2.6. Reference data
component-type:org.richfaces.Accordioncomponent-class:org.richfaces.component.UIAccordioncomponent-family:org.richfaces.Accordionrenderer-type:org.richfaces.AccordionRendererhandler-class:org.richfaces.view.facelets.html.TogglePanelTagHandler
11.2.7. Style classes and skin parameters
Table 11.2. Style classes (selectors) and corresponding skin parameters
| Class (selector) | Skin Parameters | Mapped CSS properties |
|---|---|---|
| panelBorderColor
|
border-color
|
generalBackgroundColor
|
background
| |
| panelBorderColor
|
border-bottom-color
|
headerBackgroundColor
|
background-color
| |
headerTextColor
|
color
| |
headerWeightFont
|
font-weight
| |
headerFamilyFont
|
font-family
| |
headerSizeFont
|
font-size
| |
| No skin parameters. | |
| tabDisabledTextColor
|
color
|
| No skin parameters. | |
| panelBorderColor
|
border-bottom-color
|
generalTextColor
|
color
| |
generalFamilyFont
|
font-family
| |
generalSizeFont
|
font-size
| |
| No skin parameters. | |
| No skin parameters. | |
| No skin parameters. | |
| No skin parameters. | |
| No skin parameters. | |
11.2.8. <rich:accordionItem>
The
<rich:accordionItem> component is a panel for use with the <rich:accordion> component. <rich:accordionItem> components can be added dynamically using iteration models with the <c:forEach> tag.
11.2.8.1. Basic usage
Basic usage of the
<rich:accordionItem> component requires the header attribute, which provides the text on the panel header. The panel header is all that is visible when the accordion item is collapsed.
Alternatively the
header facet could be used in place of the header attribute. This would allow for additional styles and custom content to be applied to the tab.
11.2.8.2. <rich:accordionItem> client-side events
In addition to the standard HTML events, the
<rich:accordionItem> component uses the client-side events common to all switchable panel items:
- The
enterevent points to the function to perform when the mouse enters the panel. - The
leaveevent points to the function to perform when the mouse leaves the panel.
11.2.8.3. Reference data
component-type:org.richfaces.AccordionItemcomponent-class:org.richfaces.component.UIAccordionItemcomponent-family:org.richfaces.AccordionItemrenderer-type:org.richfaces.AccordionItemRenderer
