### Create new RichFaces Documentation Jira issue

Summary
255 characters left
Description
Environment
This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.org Community Documentation

- Prev
- Next

### 6.10.3. < rich:panel > available since 3.0.0

expand all

#### 6.10.3.1. Description

A skinnable panel that is rendered as a bordered rectangle with or without a header.

Figure 6.118. <rich:panel> component

#### 6.10.3.2. Key Features

- Highly customizable look and feel

- Support for any content inside

- Header adding feature

Table 6.193. rich : panel attributes

Attribute Name | Description
--- | ---
binding | JSF: The attribute takes a value-binding expression for a component property of a backing bean
bodyClass | Assigns one or more space-separated CSS class names to the component content
header | Label text appears on a panel header
headerClass | Assigns one or more space-separated CSS class names to the component header
id | JSF: Every component may have a unique id that is automatically created if omitted
onclick | DHTML: The client-side script method to be called when the element is clicked
ondblclick | DHTML: The client-side script method to be called when the element is double-clicked
onkeydown | DHTML: The client-side script method to be called when a key is pressed down over the element
onkeypress | DHTML: The client-side script method to be called when a key is pressed over the element and released
onkeyup | DHTML: The client-side script method to be called when a key is released
onmousedown | DHTML: The client-side script method to be called when a mouse button is pressed down over the element
onmousemove | DHTML: The client-side script method to be called when a pointer is moved within the element
onmouseout | DHTML: The client-side script method to be called when a pointer is moved away from the element
onmouseover | DHTML: The client-side script method to be called when a pointer is moved onto the element
onmouseup | DHTML: The client-side script method to be called when a mouse button is released
rendered | JSF: If "false", this component is not rendered
style | HTML: CSS style rules to be applied to the component
styleClass | JSF: Assigns one or more CSS class names to the component. Corresponds to the HTML "class" attribute.

Table 6.194. Component identification parameters

Name | Value
--- | ---
component-type | org.richfaces.panel
component-class | org.richfaces.component.html.HtmlPanel
component-family | org.richfaces.panel
renderer-type | org.richfaces.PanelRenderer
tag-class | org.richfaces.taglib.PanelTag

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

Here is a simple example as it could be used on a page:

Example:

    ...

    <rich:panel header="Panel Header">

            ...

            <!--Any Content inside-->

            ...

    </rich:panel>

    ...

#### 6.10.3.4. Creating the Component Dynamically Using Java

Example:

    import org.richfaces.component.html.HtmlPanel;

    ...

    HtmlPanel myPanel = new HtmlPanel();

    ...

#### 6.10.3.5. Details of Usage

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

Example:

    ...

    <rich:panel>

            <f:facet name="header">

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

            </f:facet>

            ...

            <!--Any Content inside-->

            ...

    </rich:panel>

    ...

<rich:panel> components are used to group page content pieces on similarly formatted rectangular panels.

Example:

    ...

    <rich:panel>

            ...

    </rich:panel>

    ...

It's generating on a page in the following way:

Figure 6.119. <rich:panel> without header

The example shows that similar rectangular areas are formed with a particular style.

When creating a panel with a header element, one more <div> element is added with content defined for a header.

Example:

    ...

    <rich:panel>

            <f:facet name="header">

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

            </f:facet>

            ...

    </rich:panel>

    ...

It's displayed on a page in the following way:

Figure 6.120. <rich:panel> with header

As it has been mentioned above, the component is mostly used for a page style definition, hence the main attributes are style ones.

- "styleClass"

- "headerClass"

- "bodyClass"

Moreover, to add e.g. some JavaScript effects, events defined on it are used.

- "onmouseover"

- "onclick"

- "onmouseout"

- etc.

#### 6.10.3.6. Facets

Table 6.195. Facets

Facet name | Description
--- | ---
header | Defines the header content

#### 6.10.3.7. 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:panel> components at once:

- Redefine the corresponding skin parameters

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

#### 6.10.3.8. Skin Parameters Redefinition

Table 6.196. Skin parameters redefinition for a whole component

Skin parameters | CSS properties
--- | ---
generalBackgroundColor | background-color
panelBorderColor | border-color

Table 6.197. Skin parameters redefinition for a header element

Skin parameters | CSS properties
--- | ---
headerBackgroundColor | background-color
headerBackgroundColor | border-color
headerSizeFont | font-size
headerTextColor | color
headerWeightFont | font-weight
headerFamilyFont | font-family

Table 6.198. Skin parameters redefinition for a body element

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

#### 6.10.3.9. Definition of Custom Style Classes

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

Figure 6.121. Style classes

Table 6.199. Classes names that define a component appearance

Class name | Class description
--- | ---
rich-panel | Defines styles for a wrapper <div> element of a component
rich-panel-header | Defines styles for a header element
rich-panel-body | Defines styles for a body element

In order to redefine styles for all <rich:panel> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the table above) and define necessary properties in them. An example is placed below:

Example:

    ...

    .rich-panel-body{

        background-color: #ebf3fd;

    }

    ...

This is a result:

Figure 6.122. Redefinition styles with predefined classes

In the example a body background color was changed.

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

Example:

    ...

    .myClass{

        text-align: justify;

    }

    ...

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

Example:

    <h:panel... bodyClass="myClass"/>

This is a result:

Figure 6.123. Redefinition styles with own classes and styleClass attributes

As it could be seen on the picture above, text align of body was changed.

#### 6.10.3.10. Relevant Resources Links

On the component LiveDemo page you can see the example of <rich:panel> usage and sources for the given example.

- Prev6.10.2. < rich:paint2D > ...
- Top of page
- Front page
- Next6.10.4. < rich:panelBar > ...