Author: pete.muir(a)jboss.org
Date: 2010-06-16 21:37:20 -0400 (Wed, 16 Jun 2010)
New Revision: 6471
Modified:
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/CodeFragmentManagerImpl.java
Log:
fix pagination ;-)
Modified:
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/CodeFragmentManagerImpl.java
===================================================================
---
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/CodeFragmentManagerImpl.java 2010-06-17
01:31:29 UTC (rev 6470)
+++
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/CodeFragmentManagerImpl.java 2010-06-17
01:37:20 UTC (rev 6471)
@@ -207,6 +207,9 @@
criteria.where(predicates.toArray(new
Predicate[0])).orderBy(builder.desc(root.get(CodeFragment_.datetime)));
Query q = entityManager.createQuery(criteria);
+
+ int totalRecords = q.getResultList().size();
+
q.setFirstResult(page * PAGE_SIZE);
q.setMaxResults(PAGE_SIZE);
@@ -214,8 +217,8 @@
List<CodeFragment> codes = q.getResultList();
paginator.setPage(page);
- paginator.setRecordsCount(codes.size());
- paginator.setPagesCount(codes.size() / PAGE_SIZE);
+ paginator.setRecordsCount(totalRecords);
+ paginator.setPagesCount(totalRecords / PAGE_SIZE);
return codes;
}
Show replies by date