Class PagedListHolder<E>

java.lang.Object
org.springframework.beans.support.PagedListHolder<E>
Type Parameters:
E - the element type
All Implemented Interfaces:
Serializable

@Deprecated(since="7.0.3", forRemoval=true) public class PagedListHolder<E> extends Object implements Serializable
Deprecated, for removal: This API element is subject to removal in a future version.
as severely outdated and superseded by more modern solutions, for example in Spring Data Commons
PagedListHolder is a simple state holder for handling lists of objects, separating them into pages. Page numbering starts with 0.

This is mainly targeted 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".

Since:
19.05.2003
Author:
Juergen Hoeller
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Deprecated, for removal: This API element is subject to removal in a future version.
    The default maximum number of page links.
    static final int
    Deprecated, for removal: This API element is subject to removal in a future version.
    The default page size.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    Create a new holder instance.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Create a new holder instance with the given source list, starting with a default sort definition (with "toggleAscendingOnProperty" activated).
    Deprecated, for removal: This API element is subject to removal in a future version.
    Create a new holder instance with the given source list.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected SortDefinition
    Deprecated, for removal: This API element is subject to removal in a future version.
    Create a deep copy of the given sort definition, for use as state holder to compare a modified sort definition against.
    protected void
    doSort(List<E> source, SortDefinition sort)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Actually perform sorting of the given source list, according to the given sort definition.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the element index of the first element on the current page.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the first page to which create a link around the current page.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the element index of the last element on the current page.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the last page to which create a link around the current page.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the maximum number of page links to a few pages around the current one.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the total number of elements in the source list.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the current page number.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the number of pages for the current source list.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return a sub-list representing the current page.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the current page size.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the last time the list has been fetched from the source provider.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the sort definition for this holder.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the source list for this holder.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return if the current page is the first one.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return if the current page is the last one.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Switch to next page.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Switch to previous page.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Resort the list if necessary, i.e.
    void
    setMaxLinkedPages(int maxLinkedPages)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set the maximum number of page links to a few pages around the current one.
    void
    setPage(int page)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set the current page number.
    void
    setPageSize(int pageSize)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set the current page size.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set the sort definition for this holder.
    void
    setSource(List<E> source)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set the source list for this holder.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_PAGE_SIZE

      public static final int DEFAULT_PAGE_SIZE
      Deprecated, for removal: This API element is subject to removal in a future version.
      The default page size.
      See Also:
    • DEFAULT_MAX_LINKED_PAGES

      public static final int DEFAULT_MAX_LINKED_PAGES
      Deprecated, for removal: This API element is subject to removal in a future version.
      The default maximum number of page links.
      See Also:
  • Constructor Details

    • PagedListHolder

      public PagedListHolder()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Create a new holder instance. You'll need to set a source list to be able to use the holder.
      See Also:
    • PagedListHolder

      public PagedListHolder(List<E> source)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Create a new holder instance with the given source list, starting with a default sort definition (with "toggleAscendingOnProperty" activated).
      Parameters:
      source - the source List
      See Also:
    • PagedListHolder

      public PagedListHolder(List<E> source, SortDefinition sort)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Create a new holder instance with the given source list.
      Parameters:
      source - the source List
      sort - the SortDefinition to start with
  • Method Details

    • setSource

      public void setSource(List<E> source)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the source list for this holder.
    • getSource

      public List<E> getSource()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the source list for this holder.
    • getRefreshDate

      public @Nullable Date getRefreshDate()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the last time the list has been fetched from the source provider.
    • setSort

      public void setSort(@Nullable SortDefinition sort)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the sort definition for this holder. Typically an instance of MutableSortDefinition.
      See Also:
    • getSort

      public @Nullable SortDefinition getSort()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the sort definition for this holder.
    • setPageSize

      public void setPageSize(int pageSize)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the current page size. Resets the current page number if changed.

      Default value is 10.

    • getPageSize

      public int getPageSize()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the current page size.
    • setPage

      public void setPage(int page)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the current page number. Page numbering starts with 0.
    • getPage

      public int getPage()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the current page number. Page numbering starts with 0.
    • setMaxLinkedPages

      public void setMaxLinkedPages(int maxLinkedPages)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the maximum number of page links to a few pages around the current one.
    • getMaxLinkedPages

      public int getMaxLinkedPages()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the maximum number of page links to a few pages around the current one.
    • getPageCount

      public int getPageCount()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the number of pages for the current source list.
    • isFirstPage

      public boolean isFirstPage()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return if the current page is the first one.
    • isLastPage

      public boolean isLastPage()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return if the current page is the last one.
    • previousPage

      public void previousPage()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Switch to previous page. Will stay on first page if already on first page.
    • nextPage

      public void nextPage()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Switch to next page. Will stay on last page if already on last page.
    • getNrOfElements

      public int getNrOfElements()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the total number of elements in the source list.
    • getFirstElementOnPage

      public int getFirstElementOnPage()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the element index of the first element on the current page. Element numbering starts with 0.
    • getLastElementOnPage

      public int getLastElementOnPage()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the element index of the last element on the current page. Element numbering starts with 0.
    • getPageList

      public List<E> getPageList()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return a sub-list representing the current page.
    • getFirstLinkedPage

      public int getFirstLinkedPage()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the first page to which create a link around the current page.
    • getLastLinkedPage

      public int getLastLinkedPage()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the last page to which create a link around the current page.
    • resort

      public void resort()
      Deprecated, for removal: This API element is subject to removal in a future version.
      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.

      See Also:
    • copySortDefinition

      protected SortDefinition copySortDefinition(SortDefinition sort)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Create a deep copy of the given sort definition, for use as state holder to compare a modified sort definition against.

      Default implementation creates a MutableSortDefinition instance. Can be overridden in subclasses, in particular in case of custom extensions to the SortDefinition interface. Is allowed to return null, which means that no sort state will be held, triggering actual sorting for each resort call.

      Parameters:
      sort - the current SortDefinition object
      Returns:
      a deep copy of the SortDefinition object
      See Also:
    • doSort

      protected void doSort(List<E> source, SortDefinition sort)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Actually perform sorting of the given source list, according to the given sort definition.

      The default implementation uses Spring's PropertyComparator. Can be overridden in subclasses.

      See Also: