6.29.  < rich:datascroller >

6.29.1. Description

The component designed for providing the functionality of tables scrolling using Ajax requests.

<rich:datascroller> component

Figure 6.29.  <rich:datascroller> component


6.29.2. Key Features

  • Provides table scrolling functionality

  • Built-in Ajax processing

  • Provides fast controls

  • Skin support

Table 6.109. rich : datascroller attributes

Attribute NameDescription
actionMethodBinding 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
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
ajaxSingleIf "true", submits ONLY one field/link, instead of all form controls
alignleft|center|right [CI] Deprecated. This attribute specifies the position of the table with respect to the document. Permitted values: * left: The table is to the left of the document. * center: The table is to the center of the document. * right: The table is to the right of the document
bindingThe attribute takes a value-binding expression for a component property of a backing bean
boundaryControlsPossible values are: "show" - default mode. Controls are visible always. "hide" - controls are hidden. "auto" - unnecessary controls are hidden
bypassUpdatesIf "true", after process validations phase it skips updates of model beans on a force render response. It can be used for validating components input
dataSerialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax
eventsQueueName 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.)
fastControlsPossible values are: "show" - default mode. Controls are visible always. "hide" - controls are hidden. "auto" - unnecessary controls are hidden
fastStepThe attribute indicates pages quantity to switch onto when fast scrolling is used
focusid of element to set focus after request completed on client side
forID of the table component whose data is scrollled
handleValueCurrent handle value
idEvery component may have a unique id that is automatically created if omitted
ignoreDupResponsesAttribute 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
immediateA flag indicating that this component value must be converted and validated immediately (that is, during Apply Request Values phase), rather than waiting until a Process Validations phase
inactiveStyleCorresponds to the HTML style attribute for the inactive cell on scroller
inactiveStyleClassCorresponds to the HTML class attribute for the inactive cell on scroller
limitToListIf "true", updates on client side ONLY elements from this 'reRender' property. If "false" (default) updates all rendered by ajax region components
maxPagesMaximum quantity of pages
onbeforedomupdateJavaScript code for call before DOM has been updated on client side
onclickHTML: a script expression; a pointer button is clicked
oncompleteJavaScript code for call after request completed on client side
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
onpagechangeJavaScript handler for call after the page is changed
pageIf page >= 1 then it's a number of page to show
pageIndexVarName of variable in request scope containing index of active page
pagesVarName of variable in request scope containing number of pages
processId['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
renderedIf "false", this component is not rendered
renderIfSinglePageIf renderIfSinglePage=true then datascroller is displayed on condition that the data hold on one page
requestDelayAttribute 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
reRenderId['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
scrollerListenerMethodBinding representing an action listener method that will be notified after scrolling
selectedStyleCorresponds to the HTML style attribute for the selected cell on scroller
selectedStyleClassCorresponds to the HTML class attribute for the selected cell on scroller
statusID (in format of call UIComponent.findComponent()) of Request status component
stepControlsPossible values are: "show" - default mode. Controls are visible always. "hide" - controls are hidden. "auto" - unnecessary controls are hidden
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tableStyleCSS style(s) is/are to be applied to outside table when this component is rendered
tableStyleClassSpace-separated list of CSS style class(es) that are be applied to outside table of this component
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
valueThe current value for this component

Table 6.110. Component identification parameters

NameValue
component-typeorg.richfaces.Datascroller
component-classorg.richfaces.component.html.HtmlDatascroller
component-familyorg.richfaces.Datascroller
renderer-typeorg.richfaces.DataScrollerRenderer
tag-classorg.richfaces.taglib.DatascrollerTag

6.29.3. 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"/>
...

6.29.4. Creating the Component Dynamically Using Java

Example:


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

6.29.5. 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>
...
<rich:datascroller> controls of fast switching

Figure 6.30.  <rich:datascroller> controls of fast switching


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 is 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.png"/>
      </f:facet>
...

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

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

  • Redefine the corresponding skin parameters

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

6.29.7. Skin Parameters Redefinition

Table 6.111. Skin parameters redefinition for a wrapper element

Skin parametersCSS properties
tableBackgroundColorbackground-color
panelBorderColorborder-color

Table 6.112. Skin parameters redefinition for a button

Skin parametersCSS properties
additionalBackgroundColorbackground-color
panelBorderColorborder-color
generalFamilyFontfont-family
generalSizeFontfont-size

Table 6.113. Skin parameters redefinition for an active button

Skin parametersCSS properties
generalTextColorborder-top-color
generalTextColorcolor
generalFamilyFontfont-family
generalSizeFontfont-size

Table 6.114. Skin parameters redefinition for an inactive button

Skin parametersCSS properties
headerBackgroundColorborder-top-color
headerBackgroundColorcolor
generalFamilyFontfont-family
generalSizeFontfont-size

6.29.8. Definition of Custom Style Classes

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

Style classes

Figure 6.31. Style classes


Table 6.115. Classes names that define a component appearance

Class nameDescription
rich-datascrDefines styles for a wrapper <div> element of a datascroller
rich-dtascroller-tableDefines styles for a wrapper table element of a datascroller
rich-datascr-buttonDefines styles for a button
rich-datascr-ctrls-separatorDefines styles for a separator between buttons

Table 6.116. Classes names that define a buttons appearance

Class nameDescription
rich-datascr-actDefines styles for an active button
rich-datascr-inactDefines styles for an inactive button
rich-datascr-button-dsbldDefines 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 (possible classes could be found in the table above) and define necessary properties in them. An example is placed below:

Example:


...
.rich-datascr-button{
    
color: #CD6600;
}
...

This is a result:

Redefinition styles with predefined classes

Figure 6.32. Redefinition styles with predefined classes


In the example an input text font style was changed.

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

Example:


...
.myClass{
    
background-color: #C6E2FF;
}
...

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

Example:


<rich:datascroller ... selectedStyleClass="myClass"/>

This is a result:

Redefinition styles with own classes and styleClass attributes

Figure 6.33. Redefinition styles with own classes and styleClass attributes


As it could be seen on the picture above, background color of the selected cell on scroller was changed.

6.29.9. 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.