6.81.  < rich:toggleControl >

6.81.1. Description

A link type control for switching between togglePanel facets. Target Panel is specified with "for" attribute. It can be located inside or outside the togglePanel. As the result of switching between facets previous facet is hidden and another one (specified with "switchToState" or panel "stateOrder" attributes) is shown.

<rich:toggleControl> component

Figure 6.234.  <rich:toggleControl> component


6.81.2. Key Features

  • Highly customizable look and feel

  • Can be located anywhere in a page layout

  • Switching is provided in the three modes

    • Server

    • Client

    • Ajax

Table 6.449. rich : toggleControl attributes

Attribute NameDescription
accesskeyAccess key that, when pressed, transfers focus to this element
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", submit ONLY one field/link, instead of all form controls
bindingThe attribute takes a value-binding expression for a component property of a backing bean
bypassUpdatesIf "true", after process validations phase skip updates of model beans an force render response. Can be used for validate 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
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
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
forString, which contains id (in the format of a UIComponent.findComponent() call) of the target Toggle Panel.
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
langCode describing the language used in the generated markup for this component
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
onblurJavaScript code executed when this element loses focus
onclickJavaScript code executed when a pointer button is clicked over this element
oncompleteJavaScript code for call after request completed on client side
ondblclickJavaScript code executed when a pointer button is double clicked over this element
onfocusJavaScript code executed when this element receives focus
onkeydownJavaScript code executed when a key is pressed down over this element
onkeypressJavaScript code executed when a key is pressed and released over this element
onkeyupJavaScript code executed when a key is released over this element
onmousedownJavaScript code executed when a pointer button is pressed down over this element
onmousemoveJavaScript code executed when a pointer button is moved within this element
onmouseoutJavaScript code executed when a pointer button is moved away from this element
onmouseoverJavaScript code executed when a pointer button is moved onto this element
onmouseupJavaScript code executed when a pointer button is released over this element
panelIdAttribute defines Id for corresponding panel
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
statusID (in format of call UIComponent.findComponent()) of Request status component
styleCSS style(s) to be applied when this component is rendered
styleClassSpace-separated list of CSS style class(es) to be applied when this element is rendered. This value must be passed through as the "class" attribute on generated markup
switchToStateContains one of the facets names where target togglePanel is switched to
tabindexPosition of this element in the tabbing order for the current document. This value must be an integer between 0 and 32767
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
titleAdvisory title information about markup elements generated for this component
valueInitial value to set when rendered for the first time

Table 6.450. Component identification parameters

NameValue
component-typeorg.richfaces.ToggleControl
component-classorg.richfaces.component.html.HtmlToggleControl
component-familyorg.richfaces.ToggleControl
renderer-typeorg.richfaces.ToggleControlRenderer
tag-classorg.richfaces.taglib.ToggleControlTag

6.81.3. Creating the Component with a Page Tag

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

Example:


...
    <rich:toggleControl for="panel"/>
        ...
        <rich:togglePanel id="panel" stateOrder="[facets order to be switched]">
            <!--//Set of Facets-->
        </rich:togglePanel>
...

6.81.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlToggleControl;
...
HtmlToggleControl myControl = new HtmlToggleControl();
...

6.81.5. Details of Usage

As it was mentioned above, the control could be in any place in layout and linked to a switching panel that is managed with "for" attribute (in the "for" attribute the full component "id" is specified according to naming containers).

The togglePanel could be also switched from the side of the control instead of being strictly defined in "switchOrder" attribute of <rich:togglePanel>.

Example:


...
    <rich:togglePanel id="panel" initialState="empty" switchType="client">
        <f:facet name="first">
            <h:panelGroup>
                <rich:toggleControl for="helloForm:panel" value="Empty " switchToState="empty"/>
                <rich:toggleControl for="helloForm:panel" value=" Second" switchToState="second"/>
                ...//Some Content
            </h:panelGroup>
        </f:facet>
    <f:facet name="second">
            <h:panelGroup>
                <rich:toggleControl for="helloForm:panel" value="Empty " switchToState="empty"/>
                <rich:toggleControl for="helloForm:panel" value=" first" switchToState="first"/>
                ...//Some Content
            </h:panelGroup>
        </f:facet>
        <f:facet name="empty">
            <h:panelGroup>
                <rich:toggleControl for="helloForm:panel" value="first " switchToState="first"/>
                <rich:toggleControl for="helloForm:panel" value=" second" switchToState="second"/>
            </h:panelGroup>
        </f:facet>
    </rich:togglePanel>
...

In this example the switching is performed on facets specified in the "switchToState" attribute.

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

6.81.6. Look-and-Feel Customization

For skinnability implementation, the components use a style class redefinition method.

To redefine the appearance of all <rich:toggleControl> components at once, you should add to your style sheets style class used by a <rich:toggleControl> component.

6.81.7. Definition of Custom Style Classes

Table 6.451. Classes names that define a component appearance

Class nameDescription
rich-tglctrlDefines styles for a toggle control

In order to redefine styles for all <rich:toggleControl> components on a page using CSS, it's enough to create a class with the same name and define necessary properties in it.

To change styles of particular <rich:toggleControl> components define your own style class in the corresponding <rich:toggleControl> attributes.