|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.beans.support.PagedListHolder
org.springframework.beans.support.RefreshablePagedListHolder
RefreshablePagedListHolder is a PagedListHolder subclass with reloading capabilities. It automatically re-requests the List from the source provider, in case of Locale or filter changes.
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:
RefreshablePagedListHolder holder = request.getSession("mySessionAttr");
if (holder == null) {
holder = new RefreshablePagedListHolder();
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 PagedListSourceProvider {
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;
}
}
PagedListSourceProvider
,
LocaleEditor
,
Serialized FormField Summary |
Fields inherited from class org.springframework.beans.support.PagedListHolder |
DEFAULT_MAX_LINKED_PAGES, DEFAULT_PAGE_SIZE |
Constructor Summary | |
RefreshablePagedListHolder()
Create a new list holder. |
|
RefreshablePagedListHolder(PagedListSourceProvider sourceProvider)
Create a new list holder with the given source provider. |
Method Summary | |
java.lang.Object |
getFilter()
Return the filter that the source provider should use for loading the list. |
java.util.Locale |
getLocale()
Return the Locale that the source provider should use for loading the list. |
PagedListSourceProvider |
getSourceProvider()
Return the callback class for reloading the List when necessary. |
void |
refresh(boolean force)
Reload the underlying list from the source provider if necessary (i.e. if the locale and/or the filter has changed), and resort it. |
void |
setFilter(java.lang.Object filter)
Set the filter object that the source provider should use for loading the list. |
void |
setLocale(java.util.Locale locale)
Set the Locale that the source provider should use for loading the list. |
void |
setSourceProvider(PagedListSourceProvider sourceProvider)
Set the callback class for reloading the List when necessary. |
Methods inherited from class org.springframework.beans.support.PagedListHolder |
getFirstElementOnPage, getFirstLinkedPage, getLastElementOnPage, getLastLinkedPage, getMaxLinkedPages, getNrOfElements, getNrOfPages, getPage, getPageCount, getPageList, getPageSize, getRefreshDate, getSort, getSource, isFirstPage, isLastPage, nextPage, previousPage, resort, setMaxLinkedPages, setPage, setPageSize, setSort, setSource |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public RefreshablePagedListHolder()
setSourceProvider(org.springframework.beans.support.PagedListSourceProvider)
public RefreshablePagedListHolder(PagedListSourceProvider sourceProvider)
Method Detail |
public void setSourceProvider(PagedListSourceProvider sourceProvider)
PagedListHolder
public PagedListSourceProvider getSourceProvider()
public void setLocale(java.util.Locale locale)
locale
- the current Locale, or nullpublic java.util.Locale getLocale()
public void setFilter(java.lang.Object filter)
filter
- the filter object, or nullpublic java.lang.Object getFilter()
public void refresh(boolean force)
force
- whether a reload should be performed in any case
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |