Create new RichFaces Documentation Jira issue

This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.orgCommunity Documentation

6.6.9.  < rich:datascroller > available since 3.0.0

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


Table 6.78. rich : datascroller attributes

Attribute Name Description
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
ajaxSingleBoolean attribute which provides possibility to limit JSF tree processing(decoding, conversion/validation, value applying) to the component which send the request only. Default value is "true"
alignThis attribute specifies the position of the table with relatively to the document. Possible values are "left","center","right ". Default value is "center".
binding JSF: The attribute takes a value-binding expression for a component property of a backing bean
boundaryControlsThe attribute specifies the visibility of boundaryControls. Possible values are: "show" (controls are always visible ). "hide" (controls are hidden. "auto" (unnecessary controls are hidden). Default value is "show".
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.)
fastControlsThe attribute specifies the visibility of fastControls. Possible values are: "show" (controls are always visible ). "hide" (controls are hidden. "auto" (unnecessary controls are hidden). Default value is "show".
fastStepThe attribute indicates pages quantity to switch onto when fast scrolling is used. Default value is "0".
focusID of an element to set focus after request is completed on client side
forID of the table component whose data is scrollled
handleValueCurrent handle value
id JSF: Every 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. Default value is "true".
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
inactiveStyleCSS style rules to be applied to the scroller inactive cells
inactiveStyleClassAssigns one or more space-separated CSS class names to the scroller inactive cells
lastPageModeThe attribute to control whether last page of datascroller shows "rows" number of items or just the rest. Possible values are "full" and "short". Default value is "short".
limitToListIf "true", then of all AJAX-rendered on the page components only those will be updated, which ID's are passed to the "reRender" attribute of the describable component. "false"-the default value-means that all components with ajaxRendered="true" will be updated.
maxPagesMaximum quantity of pages. Default value is "10".
onbeforedomupdateThe client-side script method to be called before DOM is updated
onclick DHTML: The client-side script method to be called when the element is clicked
oncompleteThe client-side script method to be called after the request is completed
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
onpagechangeThe client-side script method to be called when a page is changed
pageIf page >= 1 then it's a page number 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
rendered JSF: If "false", this component is not rendered
renderIfSinglePageIf renderIfSinglePage is "true" then datascroller is displayed on condition that the data hold on one page. Default value is "true".
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
selectedStyleCSS style rules to be applied to the scroller selected cell
selectedStyleClassAssigns one or more space-separated CSS class names to the scroller selected cell
similarityGroupingIdIf there are any component requests with identical IDs then these requests will be grouped.
statusID (in format of call UIComponent.findComponent()) of Request status component
stepControlsThe attribute specifies the visibility of stepControls. Possible values are: "show" (controls are always visible ). "hide" (controls are hidden. "auto" (unnecessary controls are hidden). Default value is "show".
styleHTML: CSS style rules to be applied to the component
styleClass JSF: Assigns one or more space-separated CSS class names to the component. Corresponds to the HTML "class" attribute.
tableStyleCSS style rules to be applied to the wrapper table element of the component
tableStyleClassAssigns one or more space-separated CSS class names to the wrapper table element of the component
timeoutResponse waiting time on a particular request. If a response is not received during this time, the request is aborted
value JSF: The current value for this component

Table 6.79. 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

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

Example:


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

Example:

import org.richfaces.component.html.HtmlDatascroller;

...
HtmlDatascroller myScroll = new HtmlDatascroller();
...

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

The <rich:datascroller> component should be reRendered also with <rich:dataTable> when you changing filter in order to be updated according to the <rich:dataTable> current model.

The component should be placed into footer of the parent table or be bound to it with the "for" attribute. Note, that "for" is evaluated on view build, not on view render, that is why it will ignore JSTL tags.

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:

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

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 "page" is a value-binding attribute used to define and save current page number. The example is placed below.

Example:


...
<h:form id="myForm">
    <rich:dataTable id="carList" rows="7" value="#{dataTableScrollerBean.allCars}" var="category">
        <f:facet name="header">
            <rich:columnGroup>
                <h:column>
                    <h:outputText value="Make" />
                </h:column>
                <h:column>
                    <h:outputText value="Model" />
                </h:column>
                <h:column>
                    <h:outputText value="Price" />
                </h:column>
            </rich:columnGroup>
        </f:facet>
        <h:column>
            <h:outputText value="#{category.make}" />
        </h:column>
        <h:column>
            <h:outputText value="#{category.model}" />
        </h:column>
        <h:column>
            <h:outputText value="#{category.price}" />
        </h:column>
    </rich:dataTable>
    <rich:datascroller id="sc2" for="carList" reRender="sc1" maxPages="7" page="#{dataTableScrollerBean.scrollerPage}" />
    <h:panelGrid>
        <h:panelGroup>
            <h:outputText value="Set current page number:" />
            <h:inputText value="#{dataTableScrollerBean.scrollerPage}" id="sc1" size="1"/>
            <h:commandButton value="Set" />
        </h:panelGroup>
    </h:panelGrid>
</h:form>
...

In the example above you can enter the page number you want and set it by clicking on the <h:commandButton> . By the way, if you use <rich:datascroller> page links the input field rerenders and current page number changes.

This is a result:


The "pageIndexVar" and "pagesVar" attributes define a request scope variables and provide an ability to show the current page and the number of pages in the <rich: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}" />
        </rich:column>
        <f:facet name="footer">
            <rich:datascroller pageIndexVar="pageIndex" pagesVar="pages">
                <f:facet name="pages">
                    <h:outputText value="#{pageIndex} / #{pages}" />
                </f:facet>
            </rich:datascroller>
        </f:facet>
    </rich:dataTable>
</h:form>
...

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


 ...
<f:facet name="controlsSeparator">
          <h:graphicImage value="/image/sep.png"/>
</f:facet>
...

Starting from 3.2.1 of RichFaces multiple <rich:datascroller> instances behavior and page bindings are corrected. Incorrect page after model changes handling is added. Phase Listener called before RenderResponce scans the page for the <rich:datascroller> and performs the following operations:

  • Checks if the <rich:datascroller> is rendered. (If the checking generates an exception, the <rich:datascroller> is considered to be not rendered )

  • If the <rich:datascroller> is rendered - the table to which the <rich:datascroller> is attached gets the value of the page attribute of <rich:datascroller> .

Information about the "process" attribute usage you can find in the " Decide what to process " guide section.

Note:

Make sure, that all <rich:datascroller> components, defined for a table, have same values for all "page" attributes. The page, specified in the last "page" , will be rendered in browser.



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:





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




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:


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:


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

On the component LiveDemo page 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 on theRichFaces Users Forum.