scroller rich:Datascroller HtmlDatascroller tables

Component identification parameters

Name | Value
--- | ---
component-type | org.richfaces.Datascroller
component-class | org.richfaces.component.html.HtmlDatascroller
component-family | org.richfaces.Datascroller
renderer-type | org.richfaces.DataScrollerRenderer
tag-class | org.richfaces.taglib.DatascrollerTag

## Creating the Component with a Page Tag

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

Example:

    ...
        <h:dataTable id="table">
            ...
        </h:dataTable>
        ...
        <rich:datascroller for="table"/>
    ...

## Creating the Component Dynamically Using Java

Example:

    import org.richfaces.component.html.HtmlDatascroller;
    ...
    HtmlDatascroller myScroll = new HtmlDatascroller();
    ...

## Details of Usage

The <rich:Datascroller> component provides table scrolling functionalitity the same as TOMAHAWK scroller but with Ajax requests usage.

The component should be placed into footer of the parent table or be bound to it with the "for" attribute.

The table should also have the defined "rows" attribute limiting the quantity of inputted table rows.

The scroller could limit the maximum quantity of rendered links on the table pages with the help of the "maxPages" attribute.

Component provides two controllers groups for switching:

- Page numbers for switching onto a particular page
- The controls of fast switching: "first", "last", "next", "previous", "fastforward", "fastrewind"

The controls of fast switching are created adding the facets component with the corresponding name:

Example:

     ...
        <rich:datascroller for="table" maxPages="10">
            <f:facet name="first">
                <h:outputText value="First"/>
            </f:facet>
            <f:facet name="last">
                <h:outputText value="Last"/>
            </f:facet>
        </rich:datascroller>
    ...

Datascroller controls

The screenshot shows one controller from each group.

There are also facets used to create the disabled states: "first_disabled", "last_disabled", "next_disabled", "previous_disabled", "fastforward_disabled", "fastrewind_disabled" .

For the "fastforward"/"fastrewind" controls customization the additional "fastStep" attribute is used. The attribute indicates pages quantity to switch onto when fast scrolling is used.

The "pageIndexVar" and "pagesVar" attributes provide an ability to show the current page and the number of pages in the dataScroller. These attributes are used for definition the names of variables, that will be used in the facet with name "pages". An example can be found below:

Example:

     ...
          <h:form>
                <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5">
                      <rich:column>
                             <h:outputText value="#{cap.name}"></h:outputText>
                      </rich:column>
                      <f:facet name="footer">
                            <rich:datascroller pageIndexVar="pageIndex" pagesVar="pages">
                                    <f:facet name="pages">
                                          <h:outputText value="#{pageIndex} / #{pages}"></h:outputText>
                                    </f:facet>
                            </rich:datascroller>
                      </f:facet>
                </rich:dataTable>
          </h:form>
    ...

It's possible to insert optional separators between controls. For this purpose use a "controlSeparator" facet. An example is placed below.

     ...
          <f:facet name="controlSeparator">
                <h:graphicImage value="/image/sep.gif"/>
          </f:facet>
    ...

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

- Redefine the corresponding skin parameters

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

## Skin Parameters Redefinition

Skin parameters redefinition for a wrapper element

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

Skin parameters redefinition for a button

Skin parameters | CSS properties
--- | ---
additionalBackgroundColor | background-color
panelBorderColor | border-color
generalFamilyFont | font-family
generalSizeFont | font-size

Skin parameters redefinition for an active button

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

Skin parameters redefinition for an inactive button

Skin parameters | CSS properties
--- | ---
headerBackgroundColor | border-top-color
headerBackgroundColor | color
generalFamilyFont | font-family
generalSizeFont | font-size

## Definition of Custom Style Classes

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

Style classes

Classes names that define a component appearance

Class name | Description
--- | ---
rich-datascr | Defines styles for a wrapper <div> element of a datascroller
rich-dtascroller-table | Defines styles for a wrapper table element of a datascroller
rich-datascr-button | Defines styles for a button
rich-datascr-ctrls-separator | Defines styles for a separator between buttons

Classes names that define a buttons appearance

Class name | Description
--- | ---
rich-datascr-act | Defines styles for an active button
rich-datascr-inact | Defines styles for an inactive button
rich-datascr-button-dsbld | Defines styles for a disabled button

In order to redefine styles for all <rich:datascroller> components on a page using CSS, it's enough to create classes with the same names and define necessary properties in them.

To change styles of particular <rich:datascroller> components, define your own style classes in the corresponding <rich:datascroller> attributes.

## Relevant Resources Links

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

The solution about how to do correct pagination using datascroller (load a part of data from database) can be found on the RichFaces Users Forum.

How to use <rich:dataTable> and <rich:dataScroller> in a context of Extended Data Model see here.