Paging through a record list

If many records are returned, you can specify a paging control, using the PaginationControl complex type.

A query to the Oracle Endeca Server may return more records than can be displayed all at once. A common user interface mechanism for overcoming this is to create pages of results, where each page displays a subset of the entire result set.

The RecordList in the Results response includes pagination controls (the PaginationControl type) that you can use for paging.

The following is an example of a RecordList with a total of seven record pages and three records per page:
<cs:ContentElement xsi:type="cs:RecordList" Id="RecordList" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <cs:NumRecords>19</cs:NumRecords>
   <cs:TotalPages>7</cs:TotalPages>
   <cs:RecordRange First="1" Last="3"/>
   <cs:RecordListEntry>
   ...
   </cs:RecordListEntry>
   <cs:PaginationControl Label="First" Active="false">
      <cs:Operator OwnerId="RecordList" Page="0" xsi:type="cs:PageOperator"/>
   </cs:PaginationControl>
   <cs:PaginationControl Label="Previous" Active="false">
      <cs:Operator OwnerId="RecordList" Page="-1" xsi:type="cs:PageOperator"/>
   </cs:PaginationControl>
   <cs:PaginationControl Label="1" Active="false">
      <cs:Operator OwnerId="RecordList" Page="0" xsi:type="cs:PageOperator"/>
   </cs:PaginationControl>
   <cs:PaginationControl Label="2" Active="true">
      <cs:Operator OwnerId="RecordList" Page="1" xsi:type="cs:PageOperator"/>
   </cs:PaginationControl>
   <cs:PaginationControl Label="3" Active="true">
      <cs:Operator OwnerId="RecordList" Page="2" xsi:type="cs:PageOperator"/>
   </cs:PaginationControl>
   <cs:PaginationControl Label="Next" Active="true">
      <cs:Operator OwnerId="RecordList" Page="1" xsi:type="cs:PageOperator"/>
   </cs:PaginationControl>
   <cs:PaginationControl Label="Last" Active="true">
      <cs:Operator OwnerId="RecordList" Page="6" xsi:type="cs:PageOperator"/>
   </cs:PaginationControl>
   ...
</cs:ContentElement>
The RecordList is the initial access point for providing the paging controls for the entire record set. By default, the query returns a maximum of ten records for display. To override this setting, use the RecordsPerPage element in the RecordListConfig type, as in this example that sets five records for display:
<ContentElementConfig xsi:type="RecordListConfig" 
     HandlerFunction="RecordListHandler" 
     HandlerNamespace=""http://www.endeca.com/MDEX/conversation/1/0" 
     Id="RecordList" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <RecordsPerPage>5</RecordsPerPage>
</ContentElementConfig>
The NumRecords element in the RecordList lists the total number of records being returned by the query:
<cs:NumRecords>20</cs:NumRecords>
The default page offset for a record set is zero, meaning that the first ten records are displayed. The default offset can be overridden with the PageOperator type, as in this example that sets the offset to the third page of records:
<Operator xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xsi:type="PageOperator" OwnerId="RecordList" Page="3"/>
If the number of total pages is 1:
<cs:TotalPages>1</cs:TotalPages>
then no paging controls are needed.
If the number of total pages is 2 or greater, you can use the PaginationControl elements in the RecordList to go to the appropriate page, as indicated in the following table.
Page Label Result
First Goes to the first record page (which is page 0).
Previous Goes to the previous record page.
Next Goes to the next record page.
Last Goes to the last record page.
1 Goes to the first record page (which is page 0).
2 or greater Goes to the Nth record page.

Note that the Active attribute in a PaginationControl element indicates whether that paging control is relevant within the context of the current state. For example, if you are on the last record page, then neither the Next or Last paging controls will be active.