org.springframework.beans.support
Class RefreshablePagedListHolder

org.springframework.beans.support.PagedListHolder
  |
  +--org.springframework.beans.support.RefreshablePagedListHolder

public class RefreshablePagedListHolder
extends PagedListHolder

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;
}
}

Author:
Jean-Pierre Pawlak, Juergen Hoeller
Version: $Id: RefreshablePagedListHolder.java,v 1.1 2004/01/06 22:14:57 jhoeller Exp $
Since: 24.05.2003
See Also: PagedListSourceProvider, LocaleEditor

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
 ObjectgetFilter()
          Return the filter that the source provider should use for loading the list.
 LocalegetLocale()
          Return the Locale that the source provider should use for loading the list.
 PagedListSourceProvidergetSourceProvider()
          Return the callback class for reloading the List when necessary.
 voidrefresh(boolean force)
          Reload the underlying list from the source provider if necessary (i.e.
 voidsetFilter(Object filter)
          Set the filter object that the source provider should use for loading the list.
 voidsetLocale(Locale locale)
          Set the Locale that the source provider should use for loading the list.
 voidsetSourceProvider(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, getPageList, getPageSize, getRefreshDate, getSort, getSource, isFirstPage, isLastPage, nextPage, previousPage, resort, setMaxLinkedPages, setPage, setPageSize, setSort, setSource

Constructor Detail

RefreshablePagedListHolder

public RefreshablePagedListHolder()
Create a new list holder. You'll need to set a source provider to be able to use the holder.
See Also:
setSourceProvider(org.springframework.beans.support.PagedListSourceProvider)

RefreshablePagedListHolder

public RefreshablePagedListHolder(PagedListSourceProvider sourceProvider)
Create a new list holder with the given source provider.
Method Detail

getFilter

public Object getFilter()
Return the filter that the source provider should use for loading the list.
Returns: the current filter, or null

getLocale

public Locale getLocale()
Return the Locale that the source provider should use for loading the list.
Returns: the current Locale, or null

getSourceProvider

public PagedListSourceProvider getSourceProvider()
Return the callback class for reloading the List when necessary.

refresh

public 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.
Parameters:
force - whether a reload should be performed in any case

setFilter

public void setFilter(Object filter)
Set the filter object that the source provider should use for loading the list. This will typically be a bean, for easy data binding.
Parameters:
filter - the filter object, or null

setLocale

public void setLocale(Locale locale)
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").
Parameters:
locale - the current Locale, or null

setSourceProvider

public void setSourceProvider(PagedListSourceProvider sourceProvider)
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.
See Also:
PagedListHolder

Association Links

to Class org.springframework.beans.support.PagedListSourceProvider

to Class java.util.Locale

to Class java.util.Locale