org.springframework.beans.support
public class: RefreshablePagedListHolder [javadoc |
source]
java.lang.Object
org.springframework.beans.support.PagedListHolder
org.springframework.beans.support.RefreshablePagedListHolder
All Implemented Interfaces:
Serializable
Deprecated! as - of Spring 2.5, to be removed in Spring 3.0
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;
}
}
| Methods from org.springframework.beans.support.PagedListHolder: |
|---|
|
copySortDefinition, doSort, getFirstElementOnPage, getFirstLinkedPage, getLastElementOnPage, getLastLinkedPage, getMaxLinkedPages, getNrOfElements, getPage, getPageCount, getPageList, getPageSize, getRefreshDate, getSort, getSource, isFirstPage, isLastPage, nextPage, previousPage, resort, setMaxLinkedPages, setPage, setPageSize, setSort, setSource |
| Method from org.springframework.beans.support.RefreshablePagedListHolder Detail: |
public Object getFilter() {
return this.filter;
} Deprecated!Return the filter that the source provider should use for loading the list. |
public Locale getLocale() {
return this.locale;
} Deprecated!Return the Locale that the source provider should use for loading the list. |
public PagedListSourceProvider getSourceProvider() {
return this.sourceProvider;
} Deprecated!Return the callback class for reloading the List when necessary. |
public void refresh(boolean force) {
if (this.sourceProvider != null && (force ||
(this.locale != null && !this.locale.equals(this.localeUsed)) ||
(this.filter != null && !this.filter.equals(this.filterUsed)))) {
setSource(this.sourceProvider.loadList(this.locale, this.filter));
if (this.filter != null && !this.filter.equals(this.filterUsed)) {
this.setPage(0);
}
this.localeUsed = this.locale;
if (this.filter != null) {
this.filterUsed = BeanUtils.instantiateClass(this.filter.getClass());
BeanUtils.copyProperties(this.filter, this.filterUsed);
}
}
resort();
} Deprecated!Reload the underlying list from the source provider if necessary
(i.e. if the locale and/or the filter has changed), and resort it. |
public void setFilter(Object filter) {
this.filter = filter;
} Deprecated!Set the filter object that the source provider should use for loading the list.
This will typically be a bean, for easy data binding. |
public void setLocale(Locale locale) {
this.locale = locale;
} Deprecated!Set the Locale that the source provider should use for loading the list.
This can either be populated programmatically (e.g. with the request locale),
or via binding (using Locale's toString syntax, e.g. "locale=en_US"). |
public void setSourceProvider(PagedListSourceProvider sourceProvider) {
this.sourceProvider = sourceProvider;
} Deprecated!Set the callback class for reloading the List when necessary.
If the list is definitely not modifiable, i.e. not locale aware
and no filtering, use PagedListHolder. |