In case the Nuxeo way of handling pagination on NXQL queries results needs to be used, then these could be the steps that could be taken in order to keep things separate in a clear way.
1. Register the NXQL query in a contribution file (have as example querymodel-contrib.xml from nuxeo-platform-webapp-core module or the example bellow).
The above query is called in Nuxeo a stateless query as it has a defined pattern. A stateful query might be defined (like the one that is defined for the advanced search from Nuxeo) but most of the cases a stateless query is enough and more easy to write and use.
2. A provider needs to be defined for the above registered query.
This should be a Seam component that needs to implement org.nuxeo.ecm.platform.ui.web.api.ResultsProviderFarm interface. In case a stateless query was defined, a new provider should be defined for this stateless query. This way, in the methods that will return the result provider, the parameters that the query would need, will be provided (have a look at org.nuxeo.ecm.webapp.dashboard.DashBoardActionsBean Seam component to see how this is achieved). In case a stateful query is defined, then the already existing org.nuxeo.ecm.webapp.querymodel.QueryModelActionsBean Seam component could be used.
Below is the way a provider is defined for a registered query.
A Seam component having the name testActions should be defined. This should also implement org.nuxeo.ecm.platform.ui.web.api.ResultsProviderFarm interface (it could look something like below)
3. Define the .xhtml pages that should show the query results with pagination.
File 'test_document_listing.xhtml' could contain what the information about the search result, plus the pagination support like below
where documents is the first parameter that is provided in the first xhtml.
The above presentation does not offer support for documents list management.