spring-framework / org.springframework.beans.support / PagedListHolder

PagedListHolder

open class PagedListHolder<E : Any> : Serializable

PagedListHolder is a simple state holder for handling lists of objects, separating them into pages. Page numbering starts with 0.

This is mainly targetted at usage in web UIs. Typically, an instance will be instantiated with a list of beans, put into the session, and exported as model. The properties can all be set/get programmatically, but the most common way will be data binding, i.e. populating the bean from request parameters. The getters will mainly be used by the view.

Supports sorting the underlying list via a SortDefinition implementation, available as property "sort". By default, a MutableSortDefinition instance will be used, toggling the ascending value on setting the same property again.

The data binding names have to be called "pageSize" and "sort.ascending", as expected by BeanWrapper. Note that the names and the nesting syntax match the respective JSTL EL expressions, like "myModelAttr.pageSize" and "myModelAttr.sort.ascending".

Author
Juergen Hoeller

Since
19.05.2003

See Also
#getPageList()org.springframework.beans.support.MutableSortDefinition

Constructors

<init>

PagedListHolder()

Create a new holder instance. You'll need to set a source list to be able to use the holder.

PagedListHolder(source: MutableList<E>)

Create a new holder instance with the given source list, starting with a default sort definition (with "toggleAscendingOnProperty" activated).

PagedListHolder(source: MutableList<E>, sort: SortDefinition)

Create a new holder instance with the given source list.

Properties

DEFAULT_MAX_LINKED_PAGES

static val DEFAULT_MAX_LINKED_PAGES: Int

DEFAULT_PAGE_SIZE

static val DEFAULT_PAGE_SIZE: Int

Functions

getFirstElementOnPage

open fun getFirstElementOnPage(): Int

Return the element index of the first element on the current page. Element numbering starts with 0.

getFirstLinkedPage

open fun getFirstLinkedPage(): Int

Return the first page to which create a link around the current page.

getLastElementOnPage

open fun getLastElementOnPage(): Int

Return the element index of the last element on the current page. Element numbering starts with 0.

getLastLinkedPage

open fun getLastLinkedPage(): Int

Return the last page to which create a link around the current page.

getMaxLinkedPages

open fun getMaxLinkedPages(): Int

Return the maximum number of page links to a few pages around the current one.

getNrOfElements

open fun getNrOfElements(): Int

Return the total number of elements in the source list.

getPage

open fun getPage(): Int

Return the current page number. Page numbering starts with 0.

getPageCount

open fun getPageCount(): Int

Return the number of pages for the current source list.

getPageList

open fun getPageList(): MutableList<E>

Return a sub-list representing the current page.

getPageSize

open fun getPageSize(): Int

Return the current page size.

getRefreshDate

open fun getRefreshDate(): Date

Return the last time the list has been fetched from the source provider.

getSort

open fun getSort(): SortDefinition

Return the sort definition for this holder.

getSource

open fun getSource(): MutableList<E>

Return the source list for this holder.

isFirstPage

open fun isFirstPage(): Boolean

Return if the current page is the first one.

isLastPage

open fun isLastPage(): Boolean

Return if the current page is the last one.

nextPage

open fun nextPage(): Unit

Switch to next page. Will stay on last page if already on last page.

previousPage

open fun previousPage(): Unit

Switch to previous page. Will stay on first page if already on first page.

resort

open fun resort(): Unit

Resort the list if necessary, i.e. if the current sort instance isn't equal to the backed-up sortUsed instance.

Calls doSort to trigger actual sorting.

setMaxLinkedPages

open fun setMaxLinkedPages(maxLinkedPages: Int): Unit

Set the maximum number of page links to a few pages around the current one.

setPage

open fun setPage(page: Int): Unit

Set the current page number. Page numbering starts with 0.

setPageSize

open fun setPageSize(pageSize: Int): Unit

Set the current page size. Resets the current page number if changed.

Default value is 10.

setSort

open fun setSort(sort: SortDefinition): Unit

Set the sort definition for this holder. Typically an instance of MutableSortDefinition.

setSource

open fun setSource(source: MutableList<E>): Unit

Set the source list for this holder.