-
Notifications
You must be signed in to change notification settings - Fork 1
Pagination & Filtering
Fabrice Daugan edited this page Apr 13, 2018
·
3 revisions
@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
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
Sequence
- The JPA query is executed for you with a generated
Criteriafrom the givenUriInfo - Building the JPA pagination from the JSON request:
paging.getPageRequest(uriInfo, COLUMNS). WhereCOLUMNScorresponds to the allowed mapped properties. - Building the response:
paging.applyPagination(uriInfo, findAll)with optional item transformation.
A simple pagination dea