JavaScript Application Development API for Oracle Visual Builder Cloud Service - Classic Applications

Class: operation/js/api/PaginationRequest

Describes a request to fetch only subset of records.

First and subsequent requests to single service can be distinguished. First time caller can specify only "pageSize" to indicates how many records should be returned. All other attributes are left blank.

Subsequent request can be more specific based on what is REST service capable of and how the service responded via PaginationCursor. For example if service returned "total" amount of records then subsequest requests can specify "offset" and "pageSize" within the range.

Version:
  • 17.1.1
Source:
See:

Methods

(static) createStandard(params) → {operation/js/api/PaginationRequest}

stable API

Creates an instance of PaginationRequest.

You can pass an instance of PaginationRequest into Abcs.Operations().read(..) method to fetch just particular page of records from Application Builder custom code.

Parameters:
Name Type Description
params Object

Object literal with all possible parameters.

Properties
Name Type Attributes Default Description
pageSize Integer <optional>
15

Number of records requested to be fetched.

offset Integer <optional>
0

Offset of the first record that should be included in the result. Offset is numbered from 0. For example when "offset" is set to 5 and "pageSize" to 10, it means client is requesting 10 records starting from 6th item (including).

totalResults Integer <optional>
false

Flag whether you want to get also total count of the available records. Use wisely even if your service supports this as counting total number of records is in general more costly for a backend to calculate.

cursor operation/js/api/PaginationCursor <optional>

PaginationCursor information from the previous pagination request.

Version:
  • 17.1.1
Source:
Returns:
Type
operation/js/api/PaginationRequest
Examples

Creates an PaginationRequest instance which fetch first 30 records.

PaginationRequest.createStandard({
    pageSize: 30
});

Creates an PaginationRequest instance which fetch second 15 records.

PaginationRequest.createStandard({
    offset: 15,
    pageSize: 15
});

Creates an PaginationRequest instance which fetch first 15 records and also returns total count of available records.

PaginationRequest.createStandard({
    pageSize: 15,
    totalResult: true
});

Creates an PaginationRequest instance which fetch first 15 records and subsequently fetches second page of records using PaginationCursor.

require([
    'operation/js/api/PaginationRequest'
], function(PaginationRequest) {

    var employee = Abcs.Entities().findById('my.custom.bop.Employee');
    var firstPageRequest = PaginationRequest.createStandard({
        pageSize: 15
    });
    var operation = Abcs.Operations().read({
        entity: employee,
        pagination: firstPageRequest
    });

    operation.perform().then(function(operationResult) {
        if (operationResult.isSuccess()) {
            // Process data from the first page any way you need

            var paginationCursor = operationResult.getPaginationCursor();
            var secondPageRequest = PaginationRequest.createStandard({
                pageSize: 15,
                cursor: paginationCursor
            });
            Abcs.Operations().read({
                entity: employee,
                pagination: secondPageRequest
            }).perform().then(function(secondResult) {
                // Process data from the second page any way you need
            });
        }
    });
});