The sample shows the use of external objects provided via REST API in a CUBA Application.
The project fetches information about repositories, contributors and their details from GitHub using their public API.
-
After opening the Contributors screen (1), a user inputs organization (2).
-
Since organization is specified, the system gets all public repositories of the selected organization and provide them as a drop-down list (3), sorted from most to less popular. The most starred repository is selected by default.
Implementation: Retrofit call is implemented in
GithubRestClient#repos
. This request is called fromGithubInfoServiceBean#getRepos
, witch is triggered by thereposDl
data loader delegateContributorBrowse#reposDlLoadDelegate
. ThereposDl.load()
happens each time the organization field (2) changes its value, seeContributorBrowse#onRepoOwnerFieldValueChange
. The repos drop-down field (3) gets filled automatically as it specifiesreposDc
as its options container. -
The main table (4) loads all contributors for the selected repository (3). If there are more than 50 records, the table shows only one page, which can be changed in the table pagination controls (5).
Implementation: Retrofit call is implemented in
GithubRestClient#contributors
. This request is called fromGithubInfoServiceBean#getContributors
, witch is triggered by thecontributorsDl
data loader delegateContributorBrowse#contributorsDlLoadDelegate
. ThecontributorsDl.load()
happens each time the repository field (3) changes its value, seeContributorBrowse#onRepoNameFieldValueChange
. The table (4) gets filled automatically, because it usescontributorsDc
as its data container.Pagination (5) controls become visible because the
contributorsDl
loader has themaxResults
attribute specified:<loader id="contributorsDl" maxResults="50"/>
in the contributors browse screen. Its loader delegate calculates the page to be loaded and callsGithubInfoServiceBean#getContributors
sending requested page number and page size as parameters. -
The login links (6) click opens a window with contributor's details, including their avatar image.
Implementation: Retrofit call is implemented in
GithubRestClient#userDetails
, which returns a singleUserInfo
instance. The retrofit call is wrapped intoGithubInfoServiceBean#getUserInfo
. This service is used in theuserInfoDl
data loader delegate, seeUserInfoView#userInfoDlLoadDelegate
.The
contributorsTable
table (of the contributor browse screen) has a column generator for thelogin
column, seeContributorBrowse#contributorsTableLoginColumnGenerator
. The generator returns a link button that opens theUserInfoView
screen when clicking.