This example illustrates how to create and use custom collection datasources in your CUBA Application.
The application combines two showcases:
- Shows how to integrate 3rd party datasets, so for the example this application fetches data about currency rates through a collection datasource from this resource.
- Demonstrates how to enable pagination over your custom datasource.
The CurrencyRate entity contains information about conversion rate between two currencies. The entity is not stored in the database, getting data through CurrencyService.
CurrencyServiceBean implements CurrencyService, parsing JSON response of the 3rd party service into a collection of CurrencyRate entities.
CurrencyRateDatasource wraps CurrencyService into a collection datasource to be able to use CUBA's standard mechanisms. As an example, this class is specified as a datasource class in currency-screen.xml; so the main table of the screen is filled automatically according to the specified datasource .
To enable pagination in your custom datasource you should implement getEntities and getCount methods, as it is shown in FooCollectionDatasource and set a maximum nubmer of records to be returned in one page from the screen controller, where this datasource is used.
Based on CUBA Platform 6.3.1