|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.shept.org.springframework.beans.support.PagedListHolder<E>
public class PagedListHolder<E>
This is an extended version of the original PagedListHolder as delivered by the spring framework. The original version has implemeted a fix sorting behavior which is done in memory and cannot (easily ?) be delegated to the dataSource to be performed by a database query.
The only thing we have changed is that we made most of the local variables protected instead of private so that this behaviour can be redefined in subclasses.
added getSortUsed() getterMethod
added implements PageableList();
--- The following comment is unchanged from the original version ----
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 that toggles the ascending value on setting the same property again is used.
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".
This class just provides support for an unmodifiable List of beans. If you need on-demand refresh because of Locale or filter changes, consider RefreshablePagedListHolder.
getPageList(),
org.springframework.beans.support.RefreshablePagedListHolder,
TODO LIST_BINDING_NAME und getListBindingName() remove ?,
Serialized Form| Field Summary | |
|---|---|
private static int |
DEFAULT_MAX_LINKED_PAGES
|
protected int |
maxLinkedPages
|
protected int |
newModelSize
|
protected Object |
newModelTemplate
|
protected boolean |
newPageSet
|
protected int |
page
|
protected int |
pageSize
|
protected Date |
refreshDate
|
private static long |
serialVersionUID
|
protected org.springframework.beans.support.SortDefinition |
sort
|
protected org.springframework.beans.support.SortDefinition |
sortUsed
|
private List<E> |
source
|
| Fields inherited from interface org.shept.org.springframework.beans.support.PageableList |
|---|
DEFAULT_NEW_MODEL_SIZE, DEFAULT_PAGE_SIZE, LIST_BINDING_NAME |
| Constructor Summary | |
|---|---|
PagedListHolder()
Create a new holder instance. |
|
PagedListHolder(List<E> source)
Create a new holder instance with the given source list, starting with a default sort definition (with "toggleAscendingOnProperty" activated). |
|
PagedListHolder(List<E> source,
org.springframework.beans.support.SortDefinition sort,
Object newModelTemplate)
Create a new holder instance with the given source list. |
|
| Method Summary | |
|---|---|
protected Object |
copyModel(Object model)
Use Springs default bean copying implementation to obtain a shallow object copy |
protected org.springframework.beans.support.SortDefinition |
copySortDefinition(org.springframework.beans.support.SortDefinition s)
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> src,
org.springframework.beans.support.SortDefinition s)
Actually perform sorting of the given source list, according to the given sort definition. |
protected int |
getFirstElementOnPage_orig()
|
int |
getFirstElementOnPage()
Modifications in getFirstElementOnPage() and getLastElementOnPage()
are a workaround for a problem in jsp implementation that getLastElementOnPage()
may not return -1 (numbers below 0) which is neccessary when the list is empty
(because the first element will be 0 then and the last element must be below this value
otherwise an unexisting element might be indexed) |
int |
getFirstLinkedPage()
Return the first page to which create a link around the current page. |
protected int |
getLastElementOnPage_orig()
|
int |
getLastElementOnPage()
Modifications in getFirstElementOnPage() and getLastElementOnPage()
are a workaround for a problem in jsp implementation that getLastElementOnPage()
may not return -1 (numbers below 0) which is neccessary when the list is empty
(because the first element will be 0 then and the last element must be below this value
otherwise an unexisting element might be indexed) |
int |
getLastLinkedPage()
Return the last page to which create a link around the current page. |
String |
getListBindingName()
return the binding name of the list |
int |
getMaxLinkedPages()
Return the maximum number of page links to a few pages around the current one. |
protected List<E> |
getNewModels()
|
int |
getNewModelSize()
get the new model template (for creating new objects) |
Object |
getNewModelTemplate()
get the new model template (for creating new objects) |
int |
getNrOfElements()
Return the total number of elements in the source list. |
int |
getPage()
Return the current page number. |
int |
getPageCount()
Return the number of pages for the current source list. |
List<E> |
getPageList()
Return a sub-list representing the current page. |
int |
getPageSize()
Return the current page size. |
Date |
getRefreshDate()
Return the last time the list has been fetched from the source provider. |
org.springframework.beans.support.SortDefinition |
getSort()
Return the sort definition for this holder. |
org.springframework.beans.support.SortDefinition |
getSortUsed()
|
List<E> |
getSource()
Return the source list for this holder. |
boolean |
isEol()
Return if the underlying resultset is completely read (always true if the resultset is not based on cursors) |
boolean |
isFirstPage()
Return if the current page is the first one. |
boolean |
isLastPage()
Return if the current page is the last one. |
boolean |
isSortNeeded()
Added to the original implementation so we can check for changes and refresh the view conditionally.. |
boolean |
isVisible(Integer idx)
Return if the given element index is within the range of the currently visible Page |
void |
nextPage()
Switch to next page. |
void |
previousPage()
Switch to previous page. |
void |
resort()
Resort the list if necessary, i.e. |
void |
setMaxLinkedPages(int maxLinkedPages)
Set the maximum number of page links to a few pages around the current one. |
void |
setNewModelSize(int newModelSize)
Set the new model template (for creating new objects) |
void |
setNewModelTemplate(Object newModelTemplate)
Set a model object as a template for creating new models. |
void |
setPage(int page)
Set the current page number. |
void |
setPageSize(int pageSize)
Set the current page size. |
void |
setSort(org.springframework.beans.support.SortDefinition sort)
Set the sort definition for this holder. |
void |
setSource(List<E> source)
Set the source list for this holder. |
protected void |
setSourceInternal(List<E> source)
|
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final long serialVersionUID
private static final int DEFAULT_MAX_LINKED_PAGES
private List<E> source
protected transient Date refreshDate
protected org.springframework.beans.support.SortDefinition sort
protected org.springframework.beans.support.SortDefinition sortUsed
protected int pageSize
protected int page
protected transient boolean newPageSet
protected int maxLinkedPages
protected Object newModelTemplate
protected int newModelSize
| Constructor Detail |
|---|
public PagedListHolder()
setSource(java.util.List) public PagedListHolder(List<E> source)
source - the source ListMutableSortDefinition.setToggleAscendingOnProperty(boolean)
public PagedListHolder(List<E> source,
org.springframework.beans.support.SortDefinition sort,
Object newModelTemplate)
source - the source Listsort - the SortDefinition to start with| Method Detail |
|---|
protected org.springframework.beans.support.SortDefinition copySortDefinition(org.springframework.beans.support.SortDefinition s)
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
MutableSortDefinition.MutableSortDefinition(SortDefinition)
protected void doSort(List<E> src,
org.springframework.beans.support.SortDefinition s)
The default implementation uses Spring's PropertyComparator. Can be overridden in subclasses.
PropertyComparator.sort(java.util.List, SortDefinition)protected int getFirstElementOnPage_orig()
public int getFirstElementOnPage()
getFirstElementOnPage() and getLastElementOnPage()
are a workaround for a problem in jsp implementation that getLastElementOnPage()
may not return -1 (numbers below 0) which is neccessary when the list is empty
(because the first element will be 0 then and the last element must be below this value
otherwise an unexisting element might be indexed)
getFirstElementOnPage in interface PageableList<E>public int getFirstLinkedPage()
PageableList
getFirstLinkedPage in interface PageableList<E>protected int getLastElementOnPage_orig()
public int getLastElementOnPage()
getFirstElementOnPage() and getLastElementOnPage()
are a workaround for a problem in jsp implementation that getLastElementOnPage()
may not return -1 (numbers below 0) which is neccessary when the list is empty
(because the first element will be 0 then and the last element must be below this value
otherwise an unexisting element might be indexed)
getLastElementOnPage in interface PageableList<E>public int getLastLinkedPage()
PageableList
getLastLinkedPage in interface PageableList<E>public int getMaxLinkedPages()
PageableList
getMaxLinkedPages in interface PageableList<E>public int getNrOfElements()
PageableList
getNrOfElements in interface PageableList<E>public int getPage()
PageableList
getPage in interface PageableList<E>public int getPageCount()
PageableList
getPageCount in interface PageableList<E>public List<E> getPageList()
PageableList
getPageList in interface PageableList<E>public int getPageSize()
PageableList
getPageSize in interface PageableList<E>public Date getRefreshDate()
PageableList
getRefreshDate in interface PageableList<E>public org.springframework.beans.support.SortDefinition getSort()
PageableList
getSort in interface PageableList<E>public org.springframework.beans.support.SortDefinition getSortUsed()
getSortUsed in interface PageableList<E>public List<E> getSource()
PageableList
getSource in interface PageableList<E>public boolean isFirstPage()
PageableList
isFirstPage in interface PageableList<E>public boolean isLastPage()
PageableList
isLastPage in interface PageableList<E>public boolean isVisible(Integer idx)
PageableList
isVisible in interface PageableList<E>public void nextPage()
PageableList
nextPage in interface PageableList<E>public boolean isSortNeeded()
PageableList
isSortNeeded in interface PageableList<E>public void previousPage()
PageableList
previousPage in interface PageableList<E>public void resort()
PageableListsort instance
isn't equal to the backed-up sortUsed instance.
Calls doSort to trigger actual sorting.
resort in interface PageableList<E>#doSortpublic void setMaxLinkedPages(int maxLinkedPages)
public void setPage(int page)
PageableList
setPage in interface PageableList<E>public void setPageSize(int pageSize)
PageableListDefault value is 10.
setPageSize in interface PageableList<E>public void setSort(org.springframework.beans.support.SortDefinition sort)
PageableList
setSort in interface PageableList<E>MutableSortDefinitionpublic void setSource(List<E> source)
PageableList
setSource in interface PageableList<E>protected void setSourceInternal(List<E> source)
protected List<E> getNewModels()
protected Object copyModel(Object model)
public Object getNewModelTemplate()
PageableList
getNewModelTemplate in interface PageableList<E>public void setNewModelTemplate(Object newModelTemplate)
setNewModelTemplate in interface PageableList<E>public int getNewModelSize()
PageableList
getNewModelSize in interface PageableList<E>public void setNewModelSize(int newModelSize)
PageableList
setNewModelSize in interface PageableList<E>newRowSize - the newRowSize to setpublic boolean isEol()
PageableList
isEol in interface PageableList<E>public String getListBindingName()
PageableList
getListBindingName in interface PageableList<E>public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||