DataTables examples: Having fun with table data and Java


  • Any web application server java compatible
  • Java 1.7 (because of the use of some features like switch string statements)
  • jQuery and dateformat plugin
  • Guava
  • Apache commons lang
  • Jstl 1.2
  • Log4J

Download demo

The simple example

DataTables simple example

Server code
Javascript code
Html code:

Some notes:

With this option

Render the column not searchable and orderable for all the columns with class = not-search-orderable.

CreatedRow is a callback for the generated row. It’s a good place to put the the code for generating the progressive number on the first column

When user do a sort or search action, the progressive number must rigenerate itself. This callback function do the needed job:

The Ajax example

Ajax sample


Server code

Javascript code


From the server code, we can notice that data is put on a map that is converted to Json and sent to response

The request values belongs from the serialized form, then are decodified and splitted (using the Guava Splitter class).

The crux steps are:

The way the person’s notes are shown is slightly different from the simple example, because there’s a single div in the page that is dinamically filled by clicking on the specified column.

The date column can be formatted in this way

In order to use $ function, the dateFormat plugin is required.

The Pipeline example

The pipeline example is similar to ajax example, except for the fact that the table uses a cache control before the ajax call; the cache works for paging. Every time a new search or sorting is requested, the cache must be cleared.

The Send example


This example shows how to elaborate the existent data of a datatable and process it through the server using a form hidden field in which is a json string value is set; data is sent through a standard form post method but can be done using ajax as well.

HTML Form code
Javascript code
Server code


  1. Love your site, thank you for your examples.

    Q. How would I be able to convert the above examples from JSP to a JSF Facelets Template web app?

    Any suggestions greatly appreciated.

  2. Could not get the download example to run.

    Q. Can your component be customized where I can place a search box on one page that produces the filter results as AJAX on the same page?

    Q. Do you have SF Facelets Template web app examples?

    Any suggestions greatly appreciated.

Leave a Reply

Your email address will not be published.

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see