control rich:toggleControl HtmlToggleControl switching

Component identification parameters

Name | Value
--- | ---
component-type | org.richfaces.ToggleControl
component-class | org.richfaces.component.html.HtmlToggleControl
component-family | org.richfaces.ToggleControl
renderer-type | org.richfaces.ToggleControlRenderer
tag-class | org.richfaces.taglib.ToggleControlTag

## 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>
    ...

## Creating the Component Dynamically Using Java

Example:

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

## 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 " Decide what to process " guide section.

## 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.

## Definition of Custom Style Classes

Classes names that define a component appearance

Class name | Description
--- | ---
rich-tglctrl | Defines 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 classes with the same names (possible classes could be found in the tables above) and define necessary properties in them.

Example:

    ...
    .rich-tglctrl {
          font-family: monospace;
    }
    ...

This is a result:

Redefinition styles with predefined classes

In the example font family was changed.

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

Example:

    ...
    .myClass {
          font-style: italic;
    }
    ...

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

Example:

    <rich:toggleControl ... styleClass="myClass"/>

This is a result:

Redefinition styles with own classes and styleClass attributes

As it could be seen on the picture above, the font style was changed.