Send your remarks, comments or wishes to doc team
Subject:
Message:
Your name:
Your email:

JBoss.org Community Documentation

- Prev
- Next

## 6.85. < rich:tab >

### 6.85.1. Description

A tab section within a tab panel.

Figure 6.271. <rich:tab> component

### 6.85.2. Key Features

- Fully skinnable tabs content

- Disabled/enabled tab options

- Groups any content inside a tab

- Each tab has a unique name for a direct access (e.g. for switching between tabs)

- Switch methods can be easily customized for every tab separately with attribute to:

  - `Server`

  - `Client`

  - `AJAX`

Table 6.475. rich : tab 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 | boolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only
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 | Disables a tab in a tab panel
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
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 | Text for the actual "tab" in a tab section
labelWidth | Length for the actual "tab" in a tab section defined in pixels. If it is not defined, the length is calculated basing on a tab label text length
limitToList | If "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
name | Attribute defines tab name. Default value is "getId()".
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
onlabelclick | A JavaScript event handler; a label of the tab is clicked
onlabeldblclick | A JavaScript event handler; a pointer within label is double-clicked
onlabelkeydown | A JavaScript event handler; a key within label is pressed down
onlabelkeypress | A JavaScript event handler; a key within label is pressed and released
onlabelkeyup | A JavaScript event handler; a key within label is released
onlabelmousedown | A JavaScript event handler; a pointer within label is pressed down
onlabelmousemove | A JavaScript event handler; a pointer is moved within label
onlabelmouseup | A JavaScript event handler; a pointer within label 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
ontabenter | Event must occur on the tab which has been entered
ontableave | Event must occurs on the tab which has been left
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
similarityGroupingId | similarityGroupingId
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
switchType | Tab switch algorithm. Possible values are "client", "server", "ajax", "page".
timeout | Response waiting time on a particular request. If a response is not received during this time, the request is aborted
title | HTML: An advisory title for this element. Often displayed as a tooltip

Table 6.476. Component identification parameters

Name | Value
--- | ---
component-type | org.richfaces.Tab
component-class | org.richfaces.component.html.HtmlTab
component-family | org.richfaces.Tab
renderer-type | org.richfaces.TabRenderer
tag-class | org.richfaces.taglib.TabTag

### 6.85.3. Creating the Component with a Page Tag

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

Example:

    ...

        <rich:tabPanel>

            <!--Set of Tabs inside-->

                <rich:tab>

                    ...

                </rich:tab>

        </rich:tabPanel>

    ...

### 6.85.4. Creating the Component Dynamically Using Java

Example:

    import org.richfaces.component.html.HtmlTab;

    ...

    HtmlTab myTab = new HtmlTab();

    ...

### 6.85.5. Details of Usage

The main component function is to define a content group that is rendered and processed when the tab is active, i.e. click on a tab causes switching onto a tab containing content corresponded to this tab.

The "label" attribute defines text to be represented. If you can use the "label" facet, you can even not use the "label" attribute.

Example:

    ...

        <rich:tab>

            <f:facet name="label">

                <h:graphicImage value="/images/img1.png"/>

            </f:facet>

            ...

            <!--Any Content inside-->

            ...

        </rich:tab>

    ...

A marker on a tab header defined with the "label" attribute. Moreover, each tab could be disabled (switching on this tab is impossible) with the "disable" attribute.

Example:

    ...

        <rich:tabPanel width="20%">

            <tabs:tab  label="Canon">

            <h:outputText value="Canon EOS Digital Rebel XT" />

                  ...

          </tabs:tab>

          <tabs:tab  label="Nikon">

              <h:outputText value="Nikon D70s" />

                 ...

            </tabs:tab>

            <tabs:tab label="Olympus">

                <h:outputText value="Olympus EVOLT E-500" />

                    ...

                </tabs:tab>

                <tabs:tab disabled="true" name="disabled" label="Disabled"/>

        </rich:tabPanel>

    ...

With this example it's possible to generate the tab panel with the last disabled and three active tabs (see the picture).

Figure 6.272. <rich:tabPanel> with disabled <rich:tab>

Switching mode could be defined not only for the whole panel tab, but also for each particular tab, i.e. switching onto one tab could be performed right on the client with the corresponding JavaScript and onto another tab with an Ajax request on the server. Tab switching modes are the same as tabPanel ones.

Each tab also has an attribute name (alias for "id" attribute). Using this attribute value it's possible e.g. to set an active tab on a model level specifying this name in the corresponding attribute of the whole tab.

Except the specific component attributes it has all necessary attributes for JavaScript event definition.

- "onmouseover"

- "onmouseout"

- etc.

Some event could be performed on the tab which has been entered/left using "ontabenter" / "ontableave" attributes. See the example below.

Example:

    ...

        <rich:tabPanel>

            <rich:tab label="Tab1" ontabenter="alert()">

                ...

            </rich:tab>

            ...

        </rich:tabPanel>

    ...

The following example shows how on the client side to get the names of `entered`/`left` tabs.

    ontabenter="alert(leftTabName)"

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

### 6.85.6. Look-and-Feel Customization

For skinnability implementation, the components use a style class redefinition method. Default style classes are mapped on skin parameters.

## Note:

A panel appearance and content is defined with a tab panel i.e. on the tab level it's possible to define only an appearance of this tab header.

There are two ways to redefine the appearance of all <rich:tab> components at once:

- Redefine the corresponding skin parameters

- Add to your style sheets style classes used by a <rich:tab> component

### 6.85.7. Skin Parameters Redefinition

Table 6.477. Skin parameters redefinition for a tab header

Skin parameters | CSS properties
--- | ---
generalTextColor | color
generalSizeFont | font-size
generalFamilyFont | font-family

Table 6.478. Skin parameters redefinition for an active tab

Skin parameters | CSS properties
--- | ---
generalTextColor | color
subBorderColor | border-color
generalBackgroundColor | background-color

Table 6.479. Skin parameters redefinition for an inactive tab

Skin parameters | CSS properties
--- | ---
tabBackgroundColor | background-color
subBorderColor | border-color

Table 6.480. Skin parameters redefinition for a disabled tab

Skin parameters | CSS properties
--- | ---
tabBackgroundColor | background-color
subBorderColor | border-color
tabDisabledTextColor | color

### 6.85.8. Definition of Custom Style Classes

Figure 6.273. Classes names

Table 6.481. Classes names that define a tab

Class name | Description
--- | ---
rich-tab-header | Defines styles for a tab header
rich-tab-label | Defines styles for a tab label

Table 6.482. Classes names that define a tab states

Class name | Description
--- | ---
rich-tab-active | Defines styles for an active tab
rich-tab-inactive | Defines styles for an inactive tab
rich-tab-disabled | Defines styles for a disabled tab

In order to redefine styles for all <rich:tab> 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-tab-header{

            font-weight: bold;

    }

    ...

This is a result:

Figure 6.274. Redefinition styles with predefined classes

In the example a header font weight was changed.

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

Example:

    ...

    .myClass{

            border-color: #5d9ffc;

    }

    ...

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

Example:

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

This is a result:

Figure 6.275. Redefinition styles with own classes and styleClass attributes

As it could be seen on the picture above, the border color was changed.

- Prev6.84. < rich:tabPanel >
- Top of page
- Front page
- Next6.86. < rich:togglePanel >