本文整理汇总了Java中org.primefaces.model.LazyDataModel类的典型用法代码示例。如果您正苦于以下问题:Java LazyDataModel类的具体用法?Java LazyDataModel怎么用?Java LazyDataModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LazyDataModel类属于org.primefaces.model包,在下文中一共展示了LazyDataModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.primefaces.model.LazyDataModel; //导入依赖的package包/类
@PostConstruct
private void init(){
//initialize user acc
userAcc = usb.getUser();
model = new LazyDataModel<Job>() {
private static final long serialVersionUID = 1L;
@Override
public List<Job> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
List<Job> jobs;
int count;
if (showAll && isAdminPrivileges()){
jobs = jobFacade.findAllJobsPaginated(first, pageSize);
count = jobFacade.count();
} else {
jobs = jobFacade.findUserJobsPaginated(userAcc, first, pageSize);//sorting and filtering will not be used
count = (int)(long)jobFacade.countUserJobs(userAcc);
}
model.setRowCount(count);
return jobs;
}
};
}
示例2: init
import org.primefaces.model.LazyDataModel; //导入依赖的package包/类
@PostConstruct
private void init() {
ssapModels = new HashMap<>();
ssapStatistics = new HashMap<>();
model = new LazyDataModel<DownloadJob>() {
private static final long serialVersionUID = 1L;
@Override
public List<DownloadJob> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
List<DownloadJob> jobs = djf.findAllJobsPaginated(first, pageSize);//sorting and filtering will not be used
model.setRowCount(djf.count());
return jobs;
}
};
}
示例3: init
import org.primefaces.model.LazyDataModel; //导入依赖的package包/类
@PostConstruct
public void init() {
logger.debug("Fetching the first page of entities ...");
dataModel = new LazyDataModel<Person>() {
@Override
public List<Person> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
PersonQuery personQuery = getQuery(sortField, sortOrder, filters);
QuerySearchResult<Person> querySearchResult = persistenceService.fetch(personQuery, first, pageSize);
List<Person> result = querySearchResult.getRecords();
if (logger.isDebugEnabled()) {
logger.debug("Fetched {} entities", result.size());
}
return result;
}
};
PersonQuery personQuery = getQuery(null, null, null);
long count = persistenceService.count(personQuery);
logger.debug("Found a total of {} entities", count);
dataModel.setRowCount(Long.valueOf(count).intValue());
}
示例4: getLazyEntities
import org.primefaces.model.LazyDataModel; //导入依赖的package包/类
/**
* Getter for lazyEntities.
*
* @return Primefaces lazy data model for use with a lazy p:dataTable component.
*/
public LazyDataModel<T> getLazyEntities() {
if (lazyEntities == null) {
count();
lazyEntities = new PrimefacesLazyEntityDataModel<T>(getListingService().getDAO()) {
/** Serialization id. */
private static final long serialVersionUID = 1117380513193004406L;
/**
* @see org.primefaces.model.LazyDataModel#load(int, int, java.lang.String, org.primefaces.model.SortOrder,
* java.util.Map)
*/
@Override
public List<T> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
firstEntityIndex = first;
lastEntityIndex = first + pageSize;
retrieveEntities();
return entities;
}
};
lazyEntities.setRowCount((int) entityCount);
}
return lazyEntities;
}
示例5: fetchLazySSAPModel
import org.primefaces.model.LazyDataModel; //导入依赖的package包/类
public LazyDataModel<SSAPDownloadJobItem> fetchLazySSAPModel(final DownloadJob job) {
if (job == null) {
throw new IllegalArgumentException("passed job argument is null");
}
if (!(job instanceof SSAPDownloadJob)){
return null;//no lazy data model
}
LazyDataModel<SSAPDownloadJobItem> tmpModel = ssapModels.get(job);
if (tmpModel == null) {
//create new one
tmpModel = new LazyDataModel<SSAPDownloadJobItem>() {
private static final long serialVersionUID = 1L;
@Override
public List<SSAPDownloadJobItem> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
List<SSAPDownloadJobItem> jobs = djf.findAllSSAPItemsPaginated(job, first, pageSize);
this.setRowCount((int) djf.countSSAPItems(job));
return jobs;
}
};
ssapModels.put(job, tmpModel);
int finished = (int) djf.countFinishedSSAPItems(job);
int failed = (int) djf.countFailedSSAPItems(job);
ssapStatistics.put(job, new Statistics(finished, failed));
}
return tmpModel;
}
示例6: loadProductsModel
import org.primefaces.model.LazyDataModel; //导入依赖的package包/类
private void loadProductsModel() {
products = new LazyDataModel<Product>() {
private static final long serialVersionUID = 2895456264073910183L;
@Override
public List<Product> load(int first, int pageSize, String sortField, SortOrder sortOrder,
Map<String, Object> filters) {
return getProducts(first, pageSize);
}
@Override
public List<Product> load(int first, int pageSize, List<SortMeta> multiSortMeta, Map<String, Object> filters) {
return getProducts(first, pageSize);
}
private List<Product> getProducts(int first, int pageSize) {
List<Product> products = new ArrayList<>();
for (Product product : productMgt.getProductsList(first, pageSize)) {
product = productMgt.loadCategories(product);
products.add(product);
}
return products;
}
};
int produtosCount = productMgt.getTotalProducts();
products.setRowCount(produtosCount);
}
示例7: lazyLoad
import org.primefaces.model.LazyDataModel; //导入依赖的package包/类
public void lazyLoad() {
lazyModel = new LazyDataModel<Product>() {
@Override
public List<Product> load(int first, int pageSize,
String sortField, SortOrder sortOrder,
Map<String, Object> filters) {
String sortOrderValue = null;
if (sortField == null) {
sortField = "prodname";
}
if (sortOrder.ASCENDING.equals("A")) {
sortOrderValue = "ASC";
} else if (sortOrder.DESCENDING.equals("D")) {
sortOrderValue = "DSC";
} else {
sortOrderValue = "ASC";
}
productsInfo = dao.getAllProducts(first, pageSize, sortField,
sortOrderValue, filters);
// rowCount
int dataSize = productsInfo.size();
this.setRowCount(dataSize);
// paginate
if (dataSize > pageSize) {
try {
return productsInfo.subList(first,first + pageSize);
} catch (IndexOutOfBoundsException e) {
return productsInfo.subList(first,first + (dataSize % pageSize));
}
} else {
return productsInfo;
}
}
};
}
示例8: lazyLoad
import org.primefaces.model.LazyDataModel; //导入依赖的package包/类
public void lazyLoad() {
lazyModel = new LazyDataModel<UserPost>() {
@Override
public List<UserPost> load(int first, int pageSize,
String sortField, SortOrder sortOrder,
Map<String, Object> filters) {
String sortOrderValue = null;
if (sortField == null) {
sortField = "prodname";
}
if (sortOrder.ASCENDING.equals("A")) {
sortOrderValue = "ASC";
} else if (sortOrder.DESCENDING.equals("D")) {
sortOrderValue = "DSC";
} else {
sortOrderValue = "ASC";
}
myPosts = getAllMyPosts();
//productsInfo = dao.getAllProducts(first, pageSize, sortField, sortOrderValue, filters);
// rowCount
int dataSize = myPosts.size();
this.setRowCount(dataSize);
// paginate
if (dataSize > pageSize) {
try {
return myPosts.subList(first,first + pageSize);
} catch (IndexOutOfBoundsException e) {
return myPosts.subList(first,first + (dataSize % pageSize));
}
} else {
return myPosts;
}
}
};
}
示例9: init
import org.primefaces.model.LazyDataModel; //导入依赖的package包/类
@PostConstruct
public void init() {
lazyAccSummaryDataModel = new LazyDataModel<AccountSummary>() {
@Override
public List<AccountSummary> load(int first, int pageSize,
String sortField, SortOrder sortOrder,
Map<String, Object> filters) {
String sortOrderValue = null;
if (sortField == null) {
sortField = "investorName";
}
if (sortOrder.ASCENDING.equals("A")) {
sortOrderValue = "ASC";
} else if (sortOrder.DESCENDING.equals("D")) {
sortOrderValue = "DSC";
} else {
sortOrderValue = "default";
}
accountsInfo = dao.getAllAccounts(first, pageSize, sortField,
sortOrderValue, filters);
this.setRowCount(20);
return accountsInfo;
}
};
}
示例10: getSupportedCompliances
import org.primefaces.model.LazyDataModel; //导入依赖的package包/类
public List<String> getSupportedCompliances(){
if(((LazyDataModel)data.getValue()).getRowIndex()<0){
return Collections.EMPTY_LIST;
}
DataSet ds = (DataSet) ((LazyDataModel)data.getValue()).getRowData();
List<String> result = new ArrayList<String>();
for(Compliance compliance: dataSetService.getSupportedCompliances()){
if(ds.getComplianceUUIDs().contains(compliance.getUuid())){
result.add(compliance.getName());
}
}
return result;
}
示例11: testFindWithPrecondition
import org.primefaces.model.LazyDataModel; //导入依赖的package包/类
@Test
public void testFindWithPrecondition(){
SearchParameters sp = new SearchParameters();
sp.addFilter(Node_.status.getName(), NodeStatus.NOT_APPROVED);
LazyDataModel<Node> model = new ILCDLazyDataModel<Node>(nodeService, sp);
model.setPageSize(2);
// Assert.assertEquals(7, model.getRowCount());
}
示例12: getActiveJobs
import org.primefaces.model.LazyDataModel; //导入依赖的package包/类
public LazyDataModel<JobInstance> getActiveJobs()
{
System.out.println("1");
List<JobInstance> jis = JqmClientFactory.getClient().getActiveJobs();
System.out.println("2 - " + jis.size());
this.setWrappedData(jis);
System.out.println("3");
this.setRowCount(jis.size());
return this;
}
示例13: getListaEntidadesPaginada
import org.primefaces.model.LazyDataModel; //导入依赖的package包/类
/**
* @return lista paginada
*/
public LazyDataModel<T> getListaEntidadesPaginada() {
if (listaEntidadesPaginada == null) {
carregarListaPaginada();
}
return listaEntidadesPaginada;
}
示例14: init
import org.primefaces.model.LazyDataModel; //导入依赖的package包/类
@PostConstruct
public void init() {
@SuppressWarnings("unchecked")
final Class<T> clazz = entityClass;
data = new LazyDataModel<T>() {
private static final long serialVersionUID = 1L;
@Override
public List<T> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, String> filters) {
return persistenceService.fetch(clazz, first, pageSize);
}
};
data.setRowCount((int) persistenceService.count(entityClass));
}
示例15: getLazyDataModel
import org.primefaces.model.LazyDataModel; //导入依赖的package包/类
public LazyDataModel<Modelo> getLazyDataModel() {
if (lazyDataModel == null) {
String jpql = "select m from Modelo m";
lazyDataModel = new QueryDataModel<Modelo>(jpql);
}
return lazyDataModel;
}