1 16 17 package org.springframework.beans.support; 18 19 import java.util.Locale ; 20 21 import org.springframework.beans.BeanUtils; 22 23 73 public class RefreshablePagedListHolder extends PagedListHolder { 74 75 private PagedListSourceProvider sourceProvider; 76 77 private Locale locale; 78 79 private Locale localeUsed; 80 81 private Object filter; 82 83 private Object filterUsed; 84 85 90 public RefreshablePagedListHolder() { 91 super(); 92 } 93 94 97 public RefreshablePagedListHolder(PagedListSourceProvider sourceProvider) { 98 super(); 99 this.sourceProvider = sourceProvider; 100 } 101 102 108 public void setSourceProvider(PagedListSourceProvider sourceProvider) { 109 this.sourceProvider = sourceProvider; 110 } 111 112 115 public PagedListSourceProvider getSourceProvider() { 116 return sourceProvider; 117 } 118 119 125 public void setLocale(Locale locale) { 126 this.locale = locale; 127 } 128 129 133 public Locale getLocale() { 134 return locale; 135 } 136 137 142 public void setFilter(Object filter) { 143 this.filter = filter; 144 } 145 146 150 public Object getFilter() { 151 return filter; 152 } 153 154 159 public void refresh(boolean force) { 160 if (this.sourceProvider != null && (force || 161 (this.locale != null && !this.locale.equals(this.localeUsed)) || 162 (this.filter != null && !this.filter.equals(this.filterUsed)))) { 163 setSource(this.sourceProvider.loadList(this.locale, this.filter)); 164 if (this.filter != null && !this.filter.equals(this.filterUsed)) { 165 this.setPage(0); 166 } 167 this.localeUsed = this.locale; 168 if (null != this.filter) { 169 this.filterUsed = BeanUtils.instantiateClass(this.filter.getClass()); 170 BeanUtils.copyProperties(this.filter, this.filterUsed); 171 } 172 } 173 resort(); 174 } 175 176 } 177 | Popular Tags |