Abstract & Motivation
This example shows yet another way to allow paging behavior for our application. Here it is achieved using a Data Service that returns a subset of the data: For each Next / Previous press by the user we call the data service to get the relevant chunk of rows.
For example, for the input:
The result is a list containing the rows 6 to 10.
One big advantage of this method: The application does not need to handle big amounts of data. The other benefit we see soon.
Related documents:
Paging records in the UI - Coding our own Web Service to get Row Numbers
The application
First five records:
After pressing Next:
The Backend - SQL Example
Our data service consists of a simple SQL Query.
Code specifics:
Modeling
1. Search for the relevant data service and add it to the model.
2. In case it is a JDBC Stored Procedure, as shown here:
- Right click => Test Data Service.
- Enter input value and press Test.
- Press Add Fields to have the fields in the output port.
3. Add a Table View from the output of the service.
4. Add a Data Share element.
5. Connect the Data Share to the service, edit the link to "listen" to the "*get" event (we model its triggering in later steps).
6. Add two fields to the Data Share, index and step, as follows:
7. Define the field assigns in the Mapping link. Here we pass our SQL code the starting index and number of rows:
8. Go to the Layout Board and define the Actions for the "First" button:
- ASSIGN to reset to the first chunk of records.
- GET as a Custom Action to activate the data service (see in step 5 where we define the link activation event).
9. Define the "Previous" button: Subtract the step size from the current index:
10. Define the Enabled condition for the "Previous" button, adding the step size to the index:
11. In quite the same way, define the "Next" button:
That's it. This solution involved:
Benefit #2 (in addition to having No Big Data): Note how simple the modeling is comparing to the other paging solution:
Related documents:
Paging records in the UI - Coding our own Web Service to get Row Numbers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
38 | |
19 | |
13 | |
13 | |
11 | |
10 | |
10 | |
10 | |
8 | |
8 |