public interface Pagination extends ComponentComposition, StateValue
ComponentComposition divided into sections called
pages.
It's a "malformed" structure from a data rendering point of view, that is, the components from its minimum slot position to its maximum slot position may or may not be part of your composition.
This component has an internal state used to control which page will be displayed
during rendering, this component is determined from the current page
index.
| Modifier and Type | Method and Description |
|---|---|
void |
advance()
Advances to the next page if available.
|
void |
back()
Backs to the previous page if available.
|
boolean |
canAdvance()
Checks for pages to advance.
|
boolean |
canBack()
Checks for pages to back.
|
int |
currentPage()
The current page number.
|
int |
currentPageIndex()
The index of the current page.
|
void |
forceUpdate()
Forces the pagination to update everything internally ignoring everything, including
lazy data source to be computed again. |
char |
getLayoutTarget()
Layout target character that determines the boundary positions that this component should be
rendered.
|
boolean |
hasPage(int pageIndex)
Checks if a page exists.
|
boolean |
isAsync()
|
boolean |
isComputed()
Computed pagination usually have a
Function-like as source provider
and this provider is called each time this component is updated or the page is changed so the
current as a whole will always be the result of the source provider, regardless the current page. |
boolean |
isFirstPage()
Checks if the
current page is the first page (at index 0). |
boolean |
isLastPage()
Checks if the
current page is the last page (at lastPage()). |
boolean |
isLazy()
Lazy pagination usually have a
Function as source provider and
this provider is only called again to set the current internal source when an explicit
update is called. |
boolean |
isLoading()
If the pagination data is being loaded.
|
boolean |
isStatic()
Static pagination is a type of pagination that usually have a
Collection or
something else as source provider and this source provider is called only on first render to
set the current source as a whole, and never called again on the entire Pagination lifecycle. |
int |
lastPage()
The number of the last page.
|
int |
lastPageIndex()
The index of the last page.
|
int |
nextPage()
The number of the next page.
|
int |
nextPageIndex()
The index of the next page.
|
static java.util.List<?> |
splitSourceForPage(int index,
int pageSize,
int pagesCount,
java.util.List<?> src)
Gets all elements in a given page index based of the specified source.
|
void |
switchTo(int pageIndex)
Switches to a specific page index.
|
isContainedWithinclear, getInteractionHandler, getKey, getPosition, getReference, getRoot, getWatchingStates, hide, intersects, intersects, isManagedExternally, isVisible, render, setVisible, shouldRender, show, update, updatedgetComponents, getInternalComponentsget, getId, getState, setint currentPage()
1 if it's in the first page.int currentPageIndex()
0 if it's in the first page.int nextPage()
lastPage().int nextPageIndex()
lastPageIndex().int lastPage()
This is a shortcut to lastPageIndex() + 1.
int lastPageIndex()
Pages starts from 0 so the last page should be displayed as lastPage + 1.
boolean isFirstPage()
current page is the first page (at index 0).boolean isLastPage()
current page is the last page (at lastPage()).boolean hasPage(int pageIndex)
pageIndex - The page index to check.void switchTo(int pageIndex)
pageIndex - The page index to switch to.java.lang.IndexOutOfBoundsException - If a page with the specified index is not found.void advance()
boolean canAdvance()
true if there are pages to advance or false otherwise.void back()
boolean canBack()
true if there are pages to back or false otherwise.char getLayoutTarget()
StateValueHost.null.@ApiStatus.Internal boolean isLazy()
Function as source provider and
this provider is only called again to set the current internal source when an explicit
update is called. This kind of pagination is used to replicate a static-like pagination since
it can use a Function to provide some information to composite the source that'll be built
but will never change again.
So, when this method returns true the only way to update the current source as a
whole is triggering an update somehow e.g. by calling Component.update().
Page switches will not trigger the source provider to re-apply the current internal source.
This is an internal inventory-framework API that should not be used from outside of this library. No compatibility guarantees are provided.
@ApiStatus.Internal boolean isStatic()
Collection or
something else as source provider and this source provider is called only on first render to
set the current source as a whole, and never called again on the entire Pagination lifecycle.
This is an internal inventory-framework API that should not be used from outside of this library. No compatibility guarantees are provided.
@ApiStatus.Internal boolean isComputed()
Function-like as source provider
and this provider is called each time this component is updated or the page is changed so the
current as a whole will always be the result of the source provider, regardless the current page.
This is an internal inventory-framework API that should not be used from outside of this library. No compatibility guarantees are provided.
@ApiStatus.Internal boolean isAsync()
static, lazy and computed
types of pagination source, that is:
CompletableFuture is the type of the source provider or something
that results in a CompletableFuture. Pagination source type is defined by the implementation.
Internally asynchronous pagination also have a loading state that
tracks the loading state of the future and changes based on future completion.
This is an internal inventory-framework API that should not be used from outside of this library. No compatibility guarantees are provided.
@ApiStatus.Experimental boolean isLoading()
This API is experimental and is not subject to the general compatibility guarantees such API may be changed or may be removed completely in any further release.
false when isStatic() is true.@ApiStatus.Experimental void forceUpdate()
lazy data source to be computed again.
This API is experimental and is not subject to the general compatibility guarantees such API may be changed or may be removed completely in any further release.
forceUpdate in interface Componentstatic java.util.List<?> splitSourceForPage(int index,
int pageSize,
int pagesCount,
java.util.List<?> src)
index - The page index.pageSize - Number of elements that each page can have.pagesCount - Pre-calculated total number of pages available (set zero if not available).src - The source to split.java.lang.IndexOutOfBoundsException - If the specified index is < 0 or
exceeds the pages count.