6.82.  < rich:toolBar >

6.82.1. Description

A horizontal bar with Action items on it that accepts any JSF components as children.

<rich:toolBar> with action items

Figure 6.235.  <rich:toolBar> with action items


6.82.2. Key Features

  • Skinnable menu panel and child items

  • Standard top menu bar that can be used in accordance with a menu component

  • Grouping bar content

  • Easily place content on any side of a menu bar using predefined group layout

  • Predefined separators for menu items and groups

  • Any content inside

Table 6.452. rich : toolBar attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
contentClassA CSS style is to be applied to each element of tool bar content. Use this style, for example, to setup parameters of the font.
contentStyleA CSS style is to be applied to each element of tool bar content.
heightA height of a bar in pixels. If a height is not defined, a bar height depends of the "headerFontSize" skin parameter.
idEvery component may have a unique id that is automatically created if omitted
itemSeparatorA separator between items on a bar. Possible values are none, line, square, disc and grid.
onitemclickHTML: a script expression; a pointer button is clicked on an item
onitemdblclickHTML: a script expression; a pointer button is double-clicked on an item
onitemkeydownHTML: a script expression; a key is pressed down on an item
onitemkeypressHTML: a script expression; a key is pressed and released on an item
onitemkeyupHTML: a script expression; a key is released on an item
onitemmousedownHTML: script expression; a pointer button is pressed down on an item
onitemmousemoveHTML: a script expression; a pointer is moved on an item
onitemmouseoutHTML: a script expression; a pointer is moved away from an item
onitemmouseoverHTML: a script expression; a pointer is moved onto an item
onitemmouseupHTML: script expression; a pointer button is released on an item
renderedIf "false", this component is not rendered
separatorClassA CSS class to be applied to tool bar separators.
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
widthA width of a bar that can be defined in pixels or as percentage. The default value is 100%.

Table 6.453. Component identification parameters

NameValue
component-typeorg.richfaces.ToolBar
component-classorg.richfaces.component.html.HtmlToolBar
component-familyorg.richfaces.ToolBar
renderer-typeorg.richfaces.ToolBarRenderer
tag-classorg.richfaces.taglib.ToolBarTag

6.82.3. Creating the Component with a Page Tag

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

Example:


...
    <rich:toolBar>
        <!--//...Set of action or other JSF components-->
    </rich:toolBar>
...

6.82.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlToolBar;
...
HtmlToolBar myToolBar = new HtmlToolBar();
...

6.82.5. Details of Usage

A toolBar is a wrapper component that facilitates creation of menu and tool bars. All components defined inside are located on a stylized bar with possibility to group, arrange on the both bar sides, and place predefined separators between them.

Grouping and an input side definition is described for toolBarGroup that defines this functionality.

Separators are located between components with the help of the "itemSeparator" attribute with four predefined values:

  • none

  • line

  • square

  • disc

For example, when setting a separator of a disc type, the following result is produced:

<rich:toolBar> with a "disc" separator

Figure 6.236.  <rich:toolBar> with a "disc" separator


Moreover, for toolBar style "width" and "height" attributes are placed above all.

A custom separator can be added with the help of "itemSeparator" facet.

Example:


...
<f:facet name="itemSeparator"> 
    <rich:separator width="2" height="14" /> 
</f:facet>
...

Custom separator can be also specified by URL to the separator image in the attribute "itemSeparator" of the <rich:toolBar> .

Example:


...
<rich:toolBar id="toolBar" width="#{bean.width}" height="#{bean.height}" itemSeparator="/images/separator_img.jpg"/>
...

This is a result:

<rich:toolBar> with "itemSeparator" attribute.

Figure 6.237.  <rich:toolBar> with "itemSeparator" attribute.


As it could be seen in the picture above, the image for itemSeparator was changed.

6.82.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:toolBar> components at once:

  • Redefine the corresponding skin parameters

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

6.82.7. Skin Parameters Redefinition

Table 6.454. Skin parameters redefinition for a component exterior

Skin parametersCSS properties
panelBorderColorborder-color
headerBackgroundColorbackground-color

Table 6.455. Skin parameters redefinition for a component item

Skin parametersCSS properties
headerSizeFontfont-size
headerTextColorcolor
headerWeightFontfont-weight
headerFamilyFontfont-family

6.82.8. Definition of Custom Style Classes

Table 6.456. Classes names that define a component appearance

Class nameDescription
rich-toolbarDefines styles for a toolbar element
rich-toolbar-itemDefines styles for a toolbar item

Classes names

Figure 6.238. Classes names


In order to redefine styles for all <rich:toolBar> 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-toolbar-item{
    
font-weight:bold;
}
...

This is a result:

Redefinition styles with predefined classes

Figure 6.239. Redefinition styles with predefined classes


In the example font weight for items was changed.

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

Example:


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

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

Example:


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

This is a result:

Redefinition styles with own classes and styleClass attributes

Figure 6.240. Redefinition styles with own classes and styleClass attributes


As it could be seen on the picture above,the font style and the font weight for items was changed.

The component also has the standard attributes "style" and "styleClass" that could redefine an appearance of a particular component variants.

6.82.9. Relevant Resources Links

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