client side datatable pagination in jsf

Hi,

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}">

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

</h:datatable>

just use jQuery and use this plugin: http://neoalchemy.org/tablePagination.html

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

jQuery(document).ready(function() {
jQuery('#datatable').tablePagination();
});

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.

Advertisements

3 thoughts on “client side datatable pagination in jsf

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s