Pega's data pages support pagination. In sections for classic ui and views in constellation pagination is supported and accessible using ui features.
If you want to query a database table defining pages, for instance call a datapage with pagination from a data transform or activity to provide the data via a (REST) service, then pagination is not so obvious.
Configuring a data page with report definition referencing the datapage from data transform or activity does not provide the tools/parameter inputs necessary to use pagination.
There are however ways you can use pagination from the back end.
This article will describe the third option to use a report defintion in cobination with the pxRetrieveReportData activity. This option is in my view a balanced approach, compared to SQL connect it is for instance not necessary to know the exact database column names and no need to know SQL. In both cases knowledge about db optimization is necessary. Regarding the pega dx api, in the back end it uses the pxRetrieveReportData activity as well (when the indicated data page is sourced by a report) so in a sense using that option just adds more overhead (connector configuration in design time and api processing in run time).
pre-requisites:
Approach:
Create a wrapper activity or perhaps a data transform that will serve as entry point (data source) and takes care of setting up context input parameters and pages, map the results to a desired format/location. This rule wil call the pxRetrieveReportData activity to get the desired data.
The pxRetrieveReportData takes a couple of input parameters of which pyReportName and pyReportClass are required (refencing the report defintion sourcing the data). Also the parameters are passed to the report defintion, so any selection parameters (where clause) can be passed to the activity to take effect.
To query data with pagination it is necessary to provide a page with additional parameters:
There are roughly two approaches for controlling the amount of returned results:
The second approach seems useful for situations where you dont need to know the total amout of records, like progressively showing results until end user is satisfied. So like when scrolling down or just having a button (more/next). When you want to provide the entire set of data in consumable chunks then approach 1 seems more usefull so that its clear how many records to expect. It provides the possibility to show how many pages exits and select a specific page directly.
Properties on pyReportParamPage
| Name | Value | |||
|---|---|---|---|---|
| pxObjClass | Embed-QueryInputs | |||
| pyPagingSettings | Name | Value | ||
| pxObjClass | Embed-PagingSettings | |||
| pyPageIndex | 2 | |||
| pyPageSize | 3 | |||
| pyReturnResultCount | True | if false: pxTotalResultCount and pxPageCount not populated (will indicate 0) | ||
| pyPagingEnabled | True | returns all results if False | ||
Results on content page:
| Name | Value |
|---|---|
| pxTotalResultCount | integer value indicating total records selected by the report/query |
| pxPageCount | integer value indicating number of pages given current page size |
| pxPageSize | integer value indicationg number of rows per page |
| pxResultCount | integer value indicating number of current results |
| pxResults | page list containing the requested records/data |
Properties on pyReportParamPage
| Name | Value |
|---|---|
| pxObjClass | Embed-QueryInputs |
| pyStartIndex | integer value |
| pyRowCount | integer value |
| pyMaxRecords | optional, possible to override the max limit configured on the report definition |
Results on content page:
| Name | Value |
|---|---|
| pxTotalResultCount | not available (always indicates 0) |
| pxMore | True/False |
| pxResultCount | integer value indicating number of current results |
| pxResults | page list containing the requested records/data |
In traditional UI App an edit inpout rule could be applied to a property to change the value for instance for transformation to upper case.
In constellation UI similar can be achieved by applying a form refresh condtion combined with a data transform on the flow action related to the form.
On property change a patch call to the backend is made to run the data transform.
Edit Input Not Working in Pega 8.8 (support.pega.com)
Configuring dynamic field behavior (docs.pega.com)
Because constellation has a stateless architecuter user sessions are not maintained over requests. This has effect on debugging tools. For instance the clipboard viewer tool is not available in run time as it was before.
See article below for tools available to debug applications.
Tools for debugging constellation using tracer tool
Also, Data Page functionality and best practices have changed considerably. Because it is stateless, the Constellation architecture does not support temporary pages – you must use Data Pages instead.
For setting up a custom authentication service for API's (on service package) the following is needed:
| Rule type | Description |
|---|---|
| Authentication service rule (type custom) | Umbrella for the authentication |
| Timeout activity | Activity that optionally contains logic that will be run on timeout |
| Authentication Activity | Activity with purpose of authenticating the requestor. |
The purpose of the activity is to do the actual authentication. Successfull authentication is indicated by a couple of parameters:
The following can be used in a java step (where myStepPage is the operator page):
tools.putParamValue("pyOperPage", myStepPage);
tools.putParamValue("pyUserIdentifier", myStepPage.getString("pyUserIdentifier"));
Likely a token of some sort is expected in the http headers send by client/user to authenticate. In the authentication context the http headers can be read via following example:
ClipboardPage pxRequestorPage = tools.findPage("pxRequestor");
javax.servlet.http.HttpServletRequest request = (javax.servlet.http.HttpServletRequest) pxRequestorPage.getObject("pxHTTPServletRequest");
authToken = request.getHeader("Authorization");
In the example the Authorization header is fetch into a local variable authToken.
To summarize the flow of the activity: