Indexing and Query

Page Providers

Updated: October 16, 2020

Page providers allow retrieving items with pagination facilities, they can be used in a non-UI or non-JSF context like event listeners or core services.

For an introduction to content views, please refer to the Content Views page.

Standard Page Providers

Page provider offers many advantages comparing to hard coded NXQL query:

  • Pagination logics do not have to be coded again, the AbstractPageProvider implementation already offers corresponding logics.
  • Code duplication can be prevented, by re-using registered page providers.
  • Overriding an existing page provider definition is easy.
  • The default implementation (CoreQueryPageProvider) that handles Nuxeo documents can be switched from VCS (database) to Elasticsearch by just setting configuration in the nuxeo.conf file.
  • When using Elasticsearch, page providers support aggregation features.

Page providers can be registered on their own service and queried outside of a JSF context. These page providers can also be referenced from content views, to keep a common definition of the provider.

Content views are very linked to the rendering as they hold UI configuration and need the JSF context to resolve variables.

Since Nuxeo 6.0, page providers defined inside content views are also registered on the PageProviderService, reusing the original content view name, so that they're available outside of the content view.

Here is a sample page provider definition:

<extension target="org.nuxeo.ecm.platform.query.api.PageProviderService"

  <coreQueryPageProvider name="TREE_CHILDREN_PP">
      SELECT * FROM Document WHERE ecm:parentId = ? AND ecm:isProxy = 0 AND
      ecm:mixinType = 'Folderish' AND ecm:mixinType != 'HiddenInNavigation'
      AND ecm:isVersion = 0 AND ecm:currentLifeCycleState !=
    <sort column="dc:title" ascending="true" />


This definition is identical to the one within a content view, except it cannot use EL expressions for variables resolution.

A typical usage of this page provider would be:

PageProviderService ppService = Framework.getService(PageProviderService.class);
Map<String, Serializable> props = new HashMap<String, Serializable>();
        (Serializable) coreSession);
PageProvider<DocumentModel> pp = (PageProvider<DocumentModel>) ppService.getPageProvider(
        "TREE_CHILDREN_PP", null, null, null, props,
        new Object[] { myDoc.getId() });
List<DocumentModel> documents = pp.getCurrentPage();

Here you can see that the page provider properties (needed for the query to be executed) and its parameters (needed for the query to be built) cannot be resolved from EL expressions: they need to be given explicitly to the page provider service.

A typical usage of this page provider, referenced in a content view, would be:

<extension target="org.nuxeo.ecm.platform.ui.web.ContentViewService"

  <contentView name="TREE_CHILDREN_CV">
    <title>tree children</title>

    <pageProvider name="TREE_CHILDREN_PP">
      <property name="coreSession">#{documentManager}</property>
      <property name="checkQueryCache">true</property>



Here you can see that properties and parameters can be put on the referenced page provider as content views all have a JSF context.

Custom Page Providers

This chapter focuses on writing custom page providers, for instance when you'd like to use content views to query and display results from an external system.

The <coreQueryPageProvider> element makes it possible to answer to most common use cases. If you would like to use another kind of query, you can use an alternate element and specify the PageProvider class to use.

Here is a sample example of a custom page provider configuration:

<extension target="org.nuxeo.ecm.platform.ui.web.ContentViewService"

      <property name="coreSession">#{documentManager}</property>
        SELECT dc:title FROM Document WHERE ecm:parentId = ? AND
        ecm:isVersion = 0 AND ecm:mixinType != 'HiddenInNavigation'
        AND ecm:currentLifeCycleState != 'deleted'
      <sort column="dc:title" ascending="true" />



The <genericPageProvider> element takes an additional class attribute stating the page provider class. This class has to follow the org.nuxeo.ecm.core.api.PageProvider interface and does not need to list document models: content views do not force the item type to a given interface. The abstract class org.nuxeo.ecm.core.api.AbstractPageProvider makes it easier to define a new page provider as it implements most of the interface methods in a generic way.

As result layouts can apply to other objects than document models, their definition can be adapted to fit to the kind of results provided by the custom page provider.

In the given example, another kind of query will be performed on a core session, and will return a list of maps, each map holding the  dc:title key and corresponding value on the matching documents.

The <genericPageProvider> element accepts all the other configurations present on the <coreQueryPageProvider> element: it is up to the PageProvider implementation to use them to build its query or not. It can also perform its own caching.

The properties can be defined as EL expressions and make it possible for the query provider to have access to contextual information. In the above example, the core session to the Nuxeo repository is taken from the Seam context and passed as the property with name coreSession.

Page provider related topics

Custom Page Providers Page Provider Aggregates


We'd love to hear your thoughts!

All fields required