A request driven paging helper like Paginator, but for a listing that is expensive to load: instead of taking a pre-loaded records list, it is constructed with a supplier function that is only called, with the page size, the first time the current page is actually asked for. A second supplier resolves the total record count in the same lazy way. It reads the startPos and pageSize request parameters in its constructor and renders the same bootstrap pagination control as Paginator.


Properties

PropertyReturnsDescription
currentPageNumintThe zero based number of the page the current start position falls on.
emptybooleanWhether the current page has no records, loading them via the record supplier if they have not been fetched yet.
htmlStringRenders a standard bootstrap pagination control for the current records, with no HTML id set. A template can build its own control instead of calling this, if preferred.
maxPagesintThe maximum number of pages to show links for in the rendered pagination control.
nextbooleanWhether there is a page after the current one, based on the total record count.
pageSizeIntegerThe number of records shown per page.
previousbooleanWhether there is a page before the current one.
recordsListThe records for the current page, fetching them from the record supplier and slicing out the page on first access, then caching the result for subsequent calls. When skipToStart is false the full result of the supplier is returned unchanged.
skipToStartbooleanWhether getRecords() walks the supplier's results forward to the current start position rather than returning them unchanged.
startIntegerThe zero based index of the first record on the current page.
summaryHtmlStringA plain text summary such as "Displaying records 1 to 20 of 143", loading the total record count and the current page's records if they have not been fetched yet.
totalRecordsIntegerThe total number of records matching the query, across all pages, resolving it from the number-records supplier on first access and caching the result.

Methods

isEmpty() · getRecords() · getStart() · getPageSize() · setStart(Integer start) · setPageSize(Integer pageSize) · setPageSizeEditable(boolean pageSizeEditable) · getHtml() · getSummaryHtml() · html(String id) · isPrevious() · getCurrentPageNum() · isNext() · pageSizeHref(int newPageSize) · pageHref(int pageNum) · setRecords(List records) · getTotalRecords() · getMaxPages() · setMaxPages(int maxPages) · isSkipToStart() · setSkipToStart(boolean skipToStart) · pageSize(int i) · start(int i) · maxPages(int i) · skipToStart(boolean b) · totalRecords(int i)

isEmpty()

Returns: boolean

Whether the current page has no records, loading them via the record supplier if they have not been fetched yet.

getRecords()

Returns: List

The records for the current page, fetching them from the record supplier and slicing out the page on first access, then caching the result for subsequent calls. When skipToStart is false the full result of the supplier is returned unchanged.

getStart()

Returns: Integer

The zero based index of the first record on the current page.

getPageSize()

Returns: Integer

The number of records shown per page.

setStart(Integer start)

Returns: void

Sets the zero based index of the first record to show.

ParameterDescription
startthe start position to use. May be null

setPageSize(Integer pageSize)

Returns: void

Sets the number of records to show per page.

ParameterDescription
pageSizethe page size to use. May be null

setPageSizeEditable(boolean pageSizeEditable)

Returns: void

Sets whether the rendered pagination control includes a page size selector.

ParameterDescription
pageSizeEditabletrue to render a page size selector alongside the pagination links

getHtml()

Returns: String

Renders a standard bootstrap pagination control for the current records, with no HTML id set. A template can build its own control instead of calling this, if preferred.

getSummaryHtml()

Returns: String

A plain text summary such as "Displaying records 1 to 20 of 143", loading the total record count and the current page's records if they have not been fetched yet.

html(String id)

Returns: String

Renders a standard bootstrap pagination control for the current records, with links back to this page for each other page. Returns null when there are no records, or when all the records fit on a single page.

ParameterDescription
idthe HTML id to give the rendered list element. Treated as empty when null

isPrevious()

Returns: boolean

Whether there is a page before the current one.

getCurrentPageNum()

Returns: int

The zero based number of the page the current start position falls on.

isNext()

Returns: boolean

Whether there is a page after the current one, based on the total record count.

pageSizeHref(int newPageSize)

Returns: String

Builds a URL for the current page's query string with the page size changed and the start position reset to the beginning, for a page size selector link.

ParameterDescription
newPageSizethe page size the built URL should request

pageHref(int pageNum)

Returns: String

Builds a URL for the given page number, preserving the request's other query parameters. Returns null when the requested page starts at or past the 10000 record cutoff.

ParameterDescription
pageNumthe zero based page number to build a link for

setRecords(List records)

Returns: void

Stores the full result of the record supplier directly, bypassing the lazy fetch. Used when the caller has already resolved the records itself and only wants this paginator's rendering.

ParameterDescription
recordsthe records to store. May be null

getTotalRecords()

Returns: Integer

The total number of records matching the query, across all pages, resolving it from the number-records supplier on first access and caching the result.

getMaxPages()

Returns: int

The maximum number of pages to show links for in the rendered pagination control.

setMaxPages(int maxPages)

Returns: void

Sets the maximum number of pages to show links for in the rendered pagination control.

ParameterDescription
maxPagesthe maximum number of page links to render

isSkipToStart()

Returns: boolean

Whether getRecords() walks the supplier's results forward to the current start position rather than returning them unchanged.

setSkipToStart(boolean skipToStart)

Returns: void

Sets whether getRecords() slices out the current page from the supplier's results, or returns them unchanged.

ParameterDescription
skipToStarttrue to slice out the current page

pageSize(int i)

Returns: Paginator2

Sets the page size and returns this paginator, for chaining while building it.

ParameterDescription
ithe page size to use

start(int i)

Returns: Paginator2

Sets the start position and returns this paginator, for chaining while building it.

ParameterDescription
ithe start position to use

maxPages(int i)

Returns: Paginator2

Sets the maximum number of page links to render and returns this paginator, for chaining while building it.

ParameterDescription
ithe maximum number of page links to render

skipToStart(boolean b)

Returns: Paginator2

Sets whether getRecords() slices out the current page, and returns this paginator, for chaining while building it.

ParameterDescription
btrue to slice out the current page

totalRecords(int i)

Returns: Paginator2

Sets the total record count directly, bypassing the number-records supplier, and returns this paginator, for chaining while building it.

ParameterDescription
ithe total record count
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.