client side datatable pagination in jsf


if  you want to add simple client side pagination to a datatable in JSF, it is very simple to do so.

suppose you have this regular h:datatable in your page:

<h:dataTable id="datatable" var="item" value="#{someBean.all}">

<f:facet name="header">
<h:outputText value="my header"/>
<h:outputText value="#{item.someField}" escape="true"/>


just use jQuery and use this plugin:

include the plugins and jQuery’s js in your page and just add this to your page:

jQuery(document).ready(function() {

and that is all. It works for 1.2 and 2.0.

btw this thing is useful if you are not using PrimeFaces. PrimeFaces ease your custom needs very quickly. this solution is for a situation where you cannot use PrimeFaces some how.