Skip to content

Pagination & Filtering

Fabrice Daugan edited this page Apr 13, 2018 · 3 revisions

Code summary

@Autowired
private PaginationJson paging;
...
@GET
public TableItem<Project> findAll(@Context UriInfo uriInfo, @QueryParam(DataTableAttributes.SEARCH) String criteria) {
  Page<Project> findAll = repository.find(criteria), paging.getPageRequest(uriInfo, COLUMNS));
  return paging.applyPagination(uriInfo, findAll);
}

See PaginationJson.java

Description

Providing a lightweight filtering and pagination feature is the most complex part of UI/API interaction. There are two filter/pagination mode: managed and unmanaged

Managed filtering

Sequence

  • The JPA query is executed for you with a generated Criteria from the given UriInfo
  • Building the JPA pagination from the JSON request: paging.getPageRequest(uriInfo, COLUMNS). Where COLUMNS corresponds to the allowed mapped properties.
  • Building the response: paging.applyPagination(uriInfo, findAll) with optional item transformation.

Building the filter

Simple pagination

A simple pagination dea

Clone this wiki locally