类 PagedListHolder<E>

  • 所有已实现的接口:
    Serializable

    public class PagedListHolder<E>
    extends Object
    implements Serializable
    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".

    从以下版本开始:
    19.05.2003
    作者:
    Juergen Hoeller
    另请参阅:
    getPageList(), MutableSortDefinition, 序列化表格
    • 方法详细资料

      • setSource

        public void setSource​(List<E> source)
        Set the source list for this holder.
      • getSource

        public List<EgetSource()
        Return the source list for this holder.
      • getRefreshDate

        public Date getRefreshDate()
        Return the last time the list has been fetched from the source provider.
      • setPageSize

        public void setPageSize​(int pageSize)
        Set the current page size. Resets the current page number if changed.

        Default value is 10.

      • getPageSize

        public int getPageSize()
        Return the current page size.
      • setPage

        public void setPage​(int page)
        Set the current page number. Page numbering starts with 0.
      • getPage

        public int getPage()
        Return the current page number. Page numbering starts with 0.
      • setMaxLinkedPages

        public void setMaxLinkedPages​(int maxLinkedPages)
        Set the maximum number of page links to a few pages around the current one.
      • getMaxLinkedPages

        public int getMaxLinkedPages()
        Return the maximum number of page links to a few pages around the current one.
      • getPageCount

        public int getPageCount()
        Return the number of pages for the current source list.
      • isFirstPage

        public boolean isFirstPage()
        Return if the current page is the first one.
      • isLastPage

        public boolean isLastPage()
        Return if the current page is the last one.
      • previousPage

        public void previousPage()
        Switch to previous page. Will stay on first page if already on first page.
      • nextPage

        public void nextPage()
        Switch to next page. Will stay on last page if already on last page.
      • getNrOfElements

        public int getNrOfElements()
        Return the total number of elements in the source list.
      • getFirstElementOnPage

        public int getFirstElementOnPage()
        Return the element index of the first element on the current page. Element numbering starts with 0.
      • getLastElementOnPage

        public int getLastElementOnPage()
        Return the element index of the last element on the current page. Element numbering starts with 0.
      • getPageList

        public List<EgetPageList()
        Return a sub-list representing the current page.
      • getFirstLinkedPage

        public int getFirstLinkedPage()
        Return the first page to which create a link around the current page.
      • getLastLinkedPage

        public int getLastLinkedPage()
        Return the last page to which create a link around the current page.
      • copySortDefinition

        protected SortDefinition copySortDefinition​(SortDefinition sort)
        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.

        参数:
        sort - the current SortDefinition object
        返回:
        a deep copy of the SortDefinition object
        另请参阅:
        MutableSortDefinition(SortDefinition)