|
||||||||||
| 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>
org.shept.org.springframework.beans.support.ChoiceListHolder<E>
org.shept.org.springframework.beans.support.FilteredListHolder<E>
public class FilteredListHolder<E>
FilteredListHolder is a PagedListHolder subclass with reloading capabilities. It automatically re-requests the List from the source provider, in case of Locale or filter or sort changes. It is very similar as the RefreshablePagedListHolder but in contrast it can read portions of the query from the database so large amount of data are not a problem. It also rereads the database when changes in sorting occur.
Data binding works just like with PagedListHolder. The locale can be specified in Locale's toString syntax, e.g. "locale=en_US". The filter object can be of any custom class, preferably a bean for easy data binding from a request. An instance will simply get passed through to PagedListSourceProvider.loadList. A filter property can be specified via "filter.myFilterProperty", for example.
The scenario in the controller could be:
FilteredListHolder holder = request.getSession("mySessionAttr");
if (holder == null) {
holder = new FilteredListHolder();
holder.setSourceProvider(new MyAnonymousOrEmbeddedSourceProvider());
holder.setFilter(new MyAnonymousOrEmbeddedFilter());
request.getSession().setAttribute("mySessionAttr", holder);
}
holder.refresh(false);
BindException ex = BindUtils.bind(request, listHolder, "myModelAttr");
return ModelAndView("myViewName", ex.getModel());
...
private class MyAnonymousOrEmbeddedSourceProvider implements DatabasePagedListSourceProvider {
public List loadList(Locale locale, Object filter) {
MyAnonymousOrEmbeddedFilter filter = (MyAnonymousOrEmbeddedFilter) filter;
}
private class MyAnonymousOrEmbeddedFilter {
private String name = "";
public String getName() {
return name;
public void setName(String name) {
this.name = name;
}
}
org.springframework.beans.support.PagedListSourceProvider,
LocaleEditor,
Serialized Form| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.shept.org.springframework.beans.support.ChoiceListHolder |
|---|
ChoiceListHolder.ModelWithSelection |
| Field Summary | |
|---|---|
protected boolean |
alwaysRefresh
|
protected org.springframework.dao.support.DaoSupport |
dao
|
protected FilterDefinition |
filter
|
protected FilterDefinition |
filterInitial
|
protected FilterDefinition |
filterUsed
|
protected ScrollingListProviderFactory |
listFactory
|
protected Boolean |
reloadOnSort
|
private static long |
serialVersionUID
|
protected Boolean |
sortInMemory
|
protected ScrollingListProvider |
sourceProvider
|
| Fields inherited from class org.shept.org.springframework.beans.support.ChoiceListHolder |
|---|
options, OPTIONS_BINDING_NAME, selectedAction |
| Fields inherited from class org.shept.org.springframework.beans.support.PagedListHolder |
|---|
maxLinkedPages, newModelSize, newModelTemplate, newPageSet, page, pageSize, refreshDate, sort, sortUsed |
| Fields inherited from interface org.shept.org.springframework.beans.support.Refreshable |
|---|
FILTER_BINDING_NAME |
| Fields inherited from interface org.shept.org.springframework.beans.support.PageableList |
|---|
DEFAULT_NEW_MODEL_SIZE, DEFAULT_PAGE_SIZE, LIST_BINDING_NAME |
| Constructor Summary | |
|---|---|
FilteredListHolder()
Create a new list holder. |
|
FilteredListHolder(ScrollingListProvider sourceProvider)
Create a new list holder with the given source provider. |
|
| Method Summary | |
|---|---|
void |
clear()
Erase the list of loaded elements from the source provider Needs to do a refresh for example to populate the list again |
protected FilterDefinition |
copyFilterDefinition(FilterDefinition f)
|
protected Object |
copyModel(Object model)
Use Springs default bean copying implementation to obtain a shallow object copy |
protected void |
doSort(List<E> source,
org.springframework.beans.support.SortDefinition sort)
Actually perform sorting of the given source list, according to the given sort definition. |
int |
getDefaultLoadSize()
|
FilterDefinition |
getFilter()
Return the filter that the source provider should use for loading the list. |
FilterDefinition |
getFilterInitial()
|
FilterDefinition |
getFilterUsed()
|
ScrollingListProviderFactory |
getListFactory(org.springframework.dao.support.DaoSupport dao)
|
Boolean |
getReloadOnSort()
|
Boolean |
getSortInMemory()
|
ScrollingListProvider |
getSourceProvider()
Return the callback class for reloading the List when necessary. |
protected void |
initNewModelTemplate()
|
protected void |
initSourceProvider(org.springframework.dao.support.DaoSupport dao)
Initialize the source provider with meaningful default values. |
boolean |
isAlwaysRefresh()
|
boolean |
isEol()
Return if the underlying resultset is completely read (always true if the resultset is not based on cursors) |
protected void |
loadListFirst()
|
protected void |
loadListNext()
|
void |
refresh()
Reload the underlying list from the source provider if necessary (i.e. |
void |
refresh(org.springframework.dao.support.DaoSupport dao)
Deprecated. |
protected void |
removeNullObjects()
|
void |
setAlwaysRefresh(boolean alwaysRefresh)
|
void |
setDao(org.springframework.dao.support.DaoSupport dao)
|
void |
setFilter(FilterDefinition filter)
Set the filter object that the source provider should use for loading the list. |
void |
setFilterInitial(FilterDefinition filterInitial)
|
void |
setFilterUsed(FilterDefinition filterUsed)
|
void |
setListFactory(ScrollingListProviderFactory listFactory)
|
void |
setPage(int page)
Set the current page number. |
void |
setPageSize(int pageSize)
Set the current page size. |
void |
setReloadOnSort(Boolean reloadOnSort)
|
void |
setSortInMemory(Boolean sortInMemory)
|
void |
setSource(List<E> source)
Set the source list for this holder. |
void |
setSourceProvider(ScrollingListProvider sourceProvider)
Set the callback class for reloading the List when necessary. |
void |
setUseFilter(FilterType type)
|
String |
toString()
|
| Methods inherited from class org.shept.org.springframework.beans.support.ChoiceListHolder |
|---|
getOptions, getPageListWithSelection, getPageOptions, getSelectedAction, getSelectedItems, initOptions, setSelectedAction |
| Methods inherited from class org.shept.org.springframework.beans.support.PagedListHolder |
|---|
copySortDefinition, getFirstElementOnPage_orig, getFirstElementOnPage, getFirstLinkedPage, getLastElementOnPage_orig, getLastElementOnPage, getLastLinkedPage, getListBindingName, getMaxLinkedPages, getNewModels, getNewModelSize, getNewModelTemplate, getNrOfElements, getPage, getPageCount, getPageList, getPageSize, getRefreshDate, getSort, getSortUsed, getSource, isFirstPage, isLastPage, isSortNeeded, isVisible, nextPage, previousPage, resort, setMaxLinkedPages, setNewModelSize, setNewModelTemplate, setSort, setSourceInternal |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final long serialVersionUID
protected transient org.springframework.dao.support.DaoSupport dao
protected transient ScrollingListProviderFactory listFactory
protected transient ScrollingListProvider sourceProvider
protected FilterDefinition filter
protected FilterDefinition filterUsed
protected FilterDefinition filterInitial
protected Boolean sortInMemory
protected Boolean reloadOnSort
protected boolean alwaysRefresh
| Constructor Detail |
|---|
public FilteredListHolder()
setSourceProvider(org.shept.persistence.provider.ScrollingListProvider)public FilteredListHolder(ScrollingListProvider sourceProvider)
| Method Detail |
|---|
protected void loadListFirst()
protected void initNewModelTemplate()
protected void loadListNext()
protected void doSort(List<E> source,
org.springframework.beans.support.SortDefinition sort)
PagedListHolderThe default implementation uses Spring's PropertyComparator. Can be overridden in subclasses.
doSort in class PagedListHolder<E>PropertyComparator.sort(java.util.List, SortDefinition)protected Object copyModel(Object model)
PagedListHolder
copyModel in class PagedListHolder<E>public FilterDefinition getFilter()
getFilter in interface Refreshablenullpublic ScrollingListProvider getSourceProvider()
getSourceProvider in interface Refreshablepublic boolean isEol()
PageableList
isEol in interface PageableList<E>isEol in class PagedListHolder<E>public void clear()
public void refresh()
Refreshable
refresh in interface Refreshable@Deprecated public void refresh(org.springframework.dao.support.DaoSupport dao)
Refreshable
refresh in interface Refreshableprotected void removeNullObjects()
public void setFilter(FilterDefinition filter)
setFilter in interface Refreshablefilter - the filter object, or null
Exceptionpublic void setPage(int page)
PageableList
setPage in interface PageableList<E>setPage in class PagedListHolder<E>public void setPageSize(int pageSize)
PageableListDefault value is 10.
setPageSize in interface PageableList<E>setPageSize in class PagedListHolder<E>public void setSource(List<E> source)
setSource in interface PageableList<E>setSource in class PagedListHolder<E>public void setSourceProvider(ScrollingListProvider sourceProvider)
PagedListHolderpublic FilterDefinition getFilterUsed()
public void setFilterUsed(FilterDefinition filterUsed)
public Boolean getSortInMemory()
public void setSortInMemory(Boolean sortInMemory)
public Boolean getReloadOnSort()
public void setReloadOnSort(Boolean reloadOnSort)
public ScrollingListProviderFactory getListFactory(org.springframework.dao.support.DaoSupport dao)
public void setListFactory(ScrollingListProviderFactory listFactory)
listFactory - the listFactory to setprotected void initSourceProvider(org.springframework.dao.support.DaoSupport dao)
force - force -
Exceptionpublic int getDefaultLoadSize()
public FilterDefinition getFilterInitial()
public void setFilterInitial(FilterDefinition filterInitial)
filterInitial - the filterInitial to setprotected FilterDefinition copyFilterDefinition(FilterDefinition f)
public void setUseFilter(FilterType type)
setUseFilter in interface Refreshablepublic String toString()
toString in class PagedListHolder<E>public boolean isAlwaysRefresh()
public void setAlwaysRefresh(boolean alwaysRefresh)
alwaysRefresh - the alwaysRefresh to setpublic void setDao(org.springframework.dao.support.DaoSupport dao)
setDao in interface Refreshable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||