6.75.  < rich:simpleTogglePanel >

6.75.1. Description

A collapsible panel, which content shows/hides after activating a header control.

<rich:simpleTogglePanel> component

Figure 6.210.  <rich:simpleTogglePanel> component


6.75.2. Key Features

  • Highly customizable look and feel

  • Support for any content inside

  • Collapsing expanding content

  • Three modes of collapsing/expanding

    • Server

    • Client

    • Ajax

Table 6.416. rich : simpleTogglePanel attributes

Attribute NameDescription
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
ajaxSingleif "true", submits ONLY one field/link, instead of all form controls
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bodyClassA class that defines a style for a panel content
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
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 element to set focus after request completed on client side
headerClassClass that defines the style for panel header
heightHeight of a simple toggle panel content area might be defined as pixels or in percents. By default height is not defined
idEvery 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
labelMarker to be rendered on a panel header
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onclickHTML: a script expression; a pointer button is clicked
oncollapseEvent must occurs on befor panel collapsed
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
onexpandEvent must occurs on befor panel expanded
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
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
onmouseupHTML: script expression; a pointer button is released
openedA false value for this attribute makes a panel closed as default
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
renderedIf "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
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
switchTypeFacets switch algorithm: "client", "server"(default), "ajax"
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
valueThe current value for this component
widthWidth of a simple toggle panel might be defined as pixels or in percents. By default width is not defined

Table 6.417. Component identification parameters

NameValue
component-typeorg.richfaces.SimpleTogglePanel
component-classorg.richfaces.component.html.HtmlSimpleTogglePanel
component-familyorg.richfaces.SimpleTogglePanel
renderer-typeorg.richfaces.SimpleTogglePanelRenderer
tag-classorg.richfaces.taglib.SimpleTogglePanelTag

6.75.3. Creating the Component with a Page Tag

To create the simplest variant on a page use the following syntax:

Example:


...
<rich:simpleTogglePanel>
    ...
</rich:simpleTogglePanel>
...

6.75.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlSimpleTogglePanel;
...
HtmlSimpleTogglePanel myPanel = new HtmlSimpleTogglePanel();
...

6.75.5. Details of Usage

The component is a simplified version of toggle panel that initially has a defined layout as a panel with a header playing a role of a mode switching control. On a component header element, it's possible to define a label using an attribute with the same name.

Switching mode could be defined with the "switchType" attribute with three possible parameters.

  • Server (DEFAULT)

    The common submission is performed around simpleTogglePanel and a page is completely rendered on a called panel. Only one at a time panel is uploaded onto the client side.

  • Ajax

    AJAX form submission is performed around the panel, content of the called panel is uploaded on Ajax request and additionally specified elements in the "reRender" attribute are rendered. Only one at a time panel is uploaded on the client side.

  • Client

    All panels are uploaded on the client side. Switching from the active to the hidden panel is performed with client JavaScript.

The <rich:simpleTogglePanel> component also has an "opened" attribute responsible for keeping a panel state. It gives an opportunity to manage state of the component from a model. If the value of this attribute is"true" the component is expanded.

  • onmouseover

  • onclick

  • onmouseout

  • etc.

<rich:simpleTogglePanel> states

Figure 6.211.  <rich:simpleTogglePanel> states


Information about the "process" attribute usage you can find here.

6.75.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:simpleTooglePanel> components at once:

  • Redefine the corresponding skin parameters

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

6.75.7. Skin Parameters Redefinition

Table 6.418. Skin parameters for a whole component

Skin parametersCSS properties
generalBackgroundColorbackground-color
panelBorderColorborder-color

Table 6.419. Skin parameters for a header element

Skin parametersCSS properties
headerBackgroundColorbackground-color
headerBackgroundColorborder-color
headerSizeFontfont-size
headTextColorcolor
headerWeightFontfont-weight
headerFamilyFontfont-family

Table 6.420. Skin parameters for a body element

Skin parametersCSS properties
generalBackgroundColorbackground-color
generalSizeFontfont-size
panelTextColorcolor
generalFamilyFontfont-family

6.75.8. Definition of Custom Style Classes

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

Style classes

Figure 6.212. Style classes


Table 6.421. Classes names that define a component appearance

Class nameClass description
rich-stglpanelDefines styles for a wrapper <div> element of a component
rich-stglpanel-headerDefines styles for header element of a component
rich-stglpnl-markerDefines styles for a wrapper <div> element of a marker
rich-stglpanel-bodyDefines styles for a component content

Table 6.422. Style component classes

Class nameClass description
styleClassThe class defines panel common style. It's used in the outside <div> element
bodyClassapplicable to panels body elements
headerClassapplicable to header elements

In order to redefine styles for all <rich:simpleTogglePanel> 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-stglpanel-header{
    
font-style:italic;
}
...

This is a result:

Redefinition styles with predefined classes

Figure 6.213. Redefinition styles with predefined classes


In the example the font style for header was changed.

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

Example:


...
.myClass{
    
background-color:#ffead9;
}
...

The "bodyClass" attribute for <rich:simpleTogglePanel> is defined as it’s shown in the example below:

Example:


<rich:simpleTogglePanel ... bodyClass="myClass"/>

This is a result:

Redefinition styles with own classes and styleClass attributes

Figure 6.214. Redefinition styles with own classes and styleClass attributes


As it could be seen on the picture above,background color for body was changed.

6.75.9. Relevant Resources Links

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