rich:progressBar progressBar

Component identification parameters

Name | Value
--- | ---
component-type | org.richfaces.ProgressBar
component-family | org.richfaces.ProgressBar
renderer-type | org.richfaces.renderkit.ProgressBarRenderer
tag-class | org.richfaces.taglib.ProgressBarTag

## Creating the Component with a Page Tag

Here is a simple example of how the component can be used on a page:

Example:

    ...
    <rich:progressBar value="#{bean.incValue1}"/>
    ...

## Creating the Component Dynamically Using Java

Example:

    import org.richfaces.component.html.progressBar;
    ...
    HtmlProgressBar myProgressBar = new progressBar();
    ...

## Details of Usage

As it was mentioned above, the <rich:progressBar> component displays the status of the ongoing process. The component has a number of key attributes.

The "value" attribute sets the current value of the process. Status of the process is calculated basing on "value" attribute.

The <rich:progressBar> starts and finishes rendering its state being governed by "minValue" (default value – "0") and "maxValue" (default value is "100") attributes relatively. See the following example.

Example:

    ...
    <rich:progressBar value="#{bean.incValue}"  minValue="50"  maxValue="400"/>
    ...

The "label" attribute is responsible for displaying informational data, information on the progress bar, if it's not displayed using children components. If this attribute is not set and the children components are not used either, no textual information regarding ongoing process will be indicated. In order to indicate the current status you need to pass the value to this attribute. Please see an example.

Example:

    ...
    <rich:progressBar value="#{bean.incValue}" id="progrs" label="{value}%"/>
    ...

Displaying information on a progress bar can be also performed using <h:outputText> JSF tag within <rich:progressBar> tags passing the progress value to the value of the JSF tag.

Example:

    ...
    <rich:progressBar value="#{bean.incValue1}" >
        <h:outputText value="#{bean.incValue1}"></h:outputText>
    </rich:progressBar>
    ...

The "progressVar" attribute serves to provide an option for a value substitution on the page. It defines a variable that contains the data taken from "value" attribute. The sole purpose of the "progressVar" attribute is to provide a way to use the data placed into the "value" attribute. Please study carefully the following code example:

Example:

    ...
    <rich:progressBar value="#{bean.incValue1}" enabled="#{bean.enabled1}" id="progrs1" progressVar="progress">
        <h:outputText value="{progress}%"></h:outputText>
    </rich:progressBar>
    ...

In the shown example "progressVar" attribute gets the "progress" value which contains data taken from "value" attribute of a <rich:progressBar> and transfers the received data to the "value" attribute of <h:outputText> JSF tag, to make the data appear on the page.

The <rich:progressBar> component provides 3 predefined macrosubstitution parameters:

- {value} contains "value"

- {minValue} contains "minValue"

- {maxValue} contains "maxValue"

You can use them as follows:

Example:

    ...
    <rich:progressBar value="#{bean.incValue1}" minValue="400" maxValue="900">
            <h:outputText value="Min value is {minValue}, current value is {value}, max value is {maxValue}"></h:outputText>
    </rich:progressBar>
     ...

Macrosubstitution

The "parameters" is also a special attribute that can be used for substitutional purposes. All you need is to define a value of your own parameter (e.g parameters="param:'#{bean.incValue1}'") and you can use it to pass the data.

Example:

    ...
    <progressBar:progressBar value="#{bean.incValue1}" parameters="param:'#{bean.incValue1}'">
        <h:outputText value="{param}%"></h:outputText>
    </progressBar:progressBar>
    ...

The "interval"attribute defines the frequency of status polling. Polling is active while the component is operational.

Example:

    ...
    <rich:progressBar value="#{bean.incValue}" id="progrs" interval="900"/>
    ...

The "parameters"attribute allows to send some dynamical data to the component which is displayed in the informational part. Parameters can be passed through "parameters" attribute, or from component control.

Example:

    ...
    <rich:progressBar progressVar="progress" parameters="param1:'1'"  >
    		<h:outputText="{param1} task #{progress} %"/>
    </rich:progressBar>
    ...

The component can also employ "initial" and "complete" facets to display the states of the process: "initial" facet is displayed when the progress value is less or equal to "minValue" , and the "complete" facet is shown when the value is greater or equal to "maxValue". Please see an example below.

Example:

    ...
    <rich:progressBar value="#{bean.incValue1}" >
        <f:facet name="initial">
            <h:outputText value="Process not started"></h:outputText>
        </f:facet>
        <f:facet name="complete">
            <h:outputText value="Process completed"></h:outputText>
        </f:facet>
    </rich:progressBar>
     ...

However, the usage of these facets is optional. If you omit them nothing will be displayed.

The <rich:progressBar> component can be used in two modes: Ajax (default) and Client. In order to define the mode you need to use "mode" attribute.

- Ajax - polling is activated when the component is enabled to check its value.

- Client - component updates after its value changed through JavaScript API.

## JavaScript API

JavaScript API

Function | Description
--- | ---
enable() | Begins polling for ajax mode
disable() | Stops polling for ajax mode
setValue(value) | Updates the progress of the process
setLabel(label) | Update the label for the process

## 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:progressBar> components at once:

- Redefine the corresponding skin parameters
- Add to your style sheets style classes used by a <rich:progressBar> component

## Skin Parameters Redefinition

Skin parameters redefinition for the "completed" part of the bar with no label

Skin parameters | CSS properties
--- | ---
selectControlColor | background-color

Skin parameters redefinition for the "completed" part of the bar with a label used

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

Skin parameters redefinition for the “completed” part of the bar with a label used

Skin parameters | CSS properties
--- | ---
selectControlColor | background-color
controlBackgroundColor | color

Skin parameters redefinition for the "remained" part of the bar

Skin parameters | CSS properties
--- | ---
controlBackgroundColor | background-color
controlTextColor | color

Skin parameters redefinition for the bar itself with a label used

Skin parameters | CSS properties
--- | ---
panelBorderColor | border-color
generalFamilyFont | font-family
headerFamilyFont | font-family
generalSizeFont | font-size
controlTextColor | color

Skin parameters redefinition for the bar itself with no label used

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

## Definition of Custom Style Classes

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

Classes names

Classes names for the bar

Class name | Description
--- | ---
rich-progress-bar-shell | Defines styles for the background and the borders of the bar when label is not used
rich-progress-bar-shell-dig | Defines styles for background, font and border settings when label is used

Classes names that define "completed" part of the bar

Class name | Description
--- | ---
rich-progress-bar-uploaded | Defines styles for of "completed" progress area with no labels used
rich-progress-bar-uploaded-dig | Defines styles for that "completed" progress area with labels used
rich-progress-bar-completed | Defines styles for the "completed" progress area with a label used

Classes names that define "remained" part of the progress area

Class name | Description
--- | ---
rich-progress-bar-remained | Defines styles for the "remained" part of the bar

In order to redefine styles for all <rich:progressBar> 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-progress-bar-remained{
        background-color: #ebf3fd;
    }
    ...

This is the result:

Redefinition styles with predefined classes

In the example the "remained" part of progress area is modified with a background-color CSS property.

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

Example:

    ...
    .RremainClass{  background-color: #ebf3fd;}
    ...

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

Example:

    <rich:progressBar value="#{bean.incValue1}" styleClass="remainClass" />

This is a result:

Modificaton of a look and feel with own classes and styleClass attributes

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

## Relevant Resources Links

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