Server Side Pagination

As we are developing so many software in today’s world and dealing with millions and millions of data. Imagine a situation where you have millions of data to show on your web page. A browser will have not able to render all the data at one shot. So the best option is to go for server-side pagination, where a server will return the bounded number of rows to show in the UI.

About this Plugin

In most cases, we have a relational database or no-SQL databases which will run the query with limit, offset, ordering along with filtering/searching criteria.

There may be a situation arise where you cannot afford to run a SQL query to get the data, but you want to do support pagination.

Yes here, this plugin will have all the data’s that loaded in to server and does magic of (pagination, searching) for you.

Note: Assuming you have very good memory allocated for JVM, and GC will help us to remove the unused objects at an earlier stage.

Things that this plugin supports

  1. This allows you to use pagination with help of limit and offset
  2. One can sort the data by column
  3. Also, search the text in all column (case-insensitive) and get the relevant data
  4. It also includes the regex supports for searching, (i.e) you can pass a regular expression to find relevant data,

Let’s Learn how to use this plugin :

This plugin is written in JAVA 1.8 version.

  1. Import the project file into your application
  2. In your repository class extends the PagainationDataService and just override the getData() method as follow, This method will return the complete source data from which the plugin will take care of performing pagination and searching for you.
  3. Now, From your service or controller class, create a simple paginator object and call getPageResult as follow,
  4. A getPageResult() method will take PaginationCritera as an input which follows

    This plugin also supports search with regex as well.
  5. This Plugin allows you to fully customize the implementations, for instance, the SimplePaginator will be used for performing all pagination, searching, and sorting of an object by holding it into a memory
  6. SimplePaginator will build the output and returns the values as below
  7. You can also implement your own ITablePaginator if you wish you have any other behavior
  8. Now, assume your application uses any relation or NO-SQL database which supports pagination and filtering option by using a query.
  9. In such a case, you can still this plugin by overriding the getPageEntries(PaginationCriteria criteria) method from PaginationDataServiceBase, but remember you need to write a query with ordering, limiting, offset, and filtering clause

Points to remember :
  1.  if you want to sort a nested column, for example, An Employee object has a Company object inside it that if you wish to sort the employee using company name then you need to set the column value as “” of PaginationCriteria class.


  1. The performance of in-memory pagination is fully dependent on the machine that uses. This plugin will really help when you have tens-of-thousands of data to show on your webpage with pagination.


Thank you for reading my blog the comments and reviews are most welcomed.