Pagination details

Overview

MobileSmith supports pagination using a REST server provided ‘next page’ entry. This eliminates the need to provide client-side logic and gives the customer the most flexibility in support of their pagination needs.

 

How it works – Setup using the MobileSmith Platform

Pagination can be used for two types of REST component: List and Search&Filter.  As part of the REST AppBlock Wizard, the app designer can enter a REST URL and request a sample JSON response. Once the wizard has this sample response, the app designer can opt to use Pagination - this option is on the Available Features step of the wizard.

If the designer enables Pagination, an additional step is added to the wizard. This step will present all non-array type JSON Objects as the potential ‘Next Page’ REST call. The designer will select the desired JSON object and complete the remaining steps. 

 

NOTE: The REST URL used for pagination must be a fully qualified URL and must support SSL (HTTPS).

 

How it works – Mobile App behavior

On a list page of the mobile app, when the list is near the bottom of the current list items, the app will call the selected pagination REST URL (defined in the Platform Wizard step). The results will be added to the end of the existing list. If the REST JSON does not return the configured pagination JSON object, the app will not call a pagination REST URL and allow the scrolling list to end.

 

 

An example could look like this:

The REST Server creates a JSON object called nextPage and populates it with two variables page & limit. This tells the REST Server, on the next call, to return up to 10 records starting with the 11th record. If there are more than 20 records to return, without pagination, add a nextPage JSON object to support further pagination.

 

 

Current Pages URL: "https://restserver/api/employees/paginate?page=1&limit=10",

JSON Body
{
  "nextPage": "https://restserver/api/employees/paginate?page=2&limit=10",
  "results": [ …






  ]
}

 

When the user scrolls near the bottom of the list, the pagination app feature will call: "https://restserver/api/employees/paginate?page=2&limit=10" and add the JSON results to the bottom of the existing list.

And the 20th paginated page would be

Current Pages URL: "https//restserver/api/employees/paginate?page=20&limit=10",

{
  "nextPage": "https://restserver/api/employees/paginate?page=21&limit=10",
  "results": [ …
  ]
}

 

…etc until the last page:

{
  "results": [ …
  ]
}

 

…end of list

Since there is no nextPage JSON object in the last JSON Body, pagination process will not be called.

Click here to return to the REST Wizard page.