Standard way to implementing pagination in a module?

Please, is there an example, or a custom(standard) way to implement pagination in my openMRS module’s views?

Are you developing a module for OpenMRS 2.x or a plain platform?

@raff I am developing on openMRS version 1.11.3 - Standard installation (not version 2.x reference app)

Sorry for the late response. If you think about including a paginated table then have a look at the usage of DatatableRequest and DatatableResponse in

https://github.com/openmrs/openmrs-core/blob/master/web/src/main/java/org/openmrs/web/controller/visit/VisitListController.java

2 Likes

While @raff’s answer is the more standard OpenMRS-way to do paging, we have done it a bit differently in the OpenHMIS modules. We do the paging at the database (as does OpenMRS, I think) and added paging as a core feature of our common data layer. This means that your module code does not have to worry about how to properly setup the criteria to get the proper paged records.

An example of this is in our Inventory module in the IItemDataService.getItemsByDepartment function:

The implementation code for this function only deals with the core logic of returning a list filtered by Department. The paging logic is handled in a standard way for all entities by the PagingInfo class and the executeCriteria helper function in the BaseObjectDataServiceImpl base class (defined in the OpenHMIS Commons module).

https://github.com/OpenHMIS/openmrs-module-openhmis.commons/blob/develop/api/src/main/java/org/openmrs/module/openhmis/commons/api/entity/impl/BaseObjectDataServiceImpl.java#L246

We’ve found this framework and associated patterns very helpful to quickly create correct data access services.

2 Likes