Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <p:dataTable value="#{productListMg.productsListLazy}"
- lazy="true"
- paginatorPosition="top"
- paginator="true"
- paginatorAlwaysVisible="false"
- rows="12"
- var="prd" rowIndexVar="rowIndex" id="productTb"
- styleClass="horizontal-line-table inline-button">
- @ManagedBean
- @ViewScoped
- public class ProductListMg {
- public ProductListMg()
- {
- productsListLazy=new NamingBaseLazyModel(Product.class);
- }
- }
- @Override
- public List load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
- return NamingDl.getInstance().loadNamingObjectsLazy(cls, first, pageSize, sortField, sortOrder, filters);
- }
- @Override
- public int getRowCount() {
- return NamingDl.getInstance().getNamingLazyObjectSize(cls);
- }
- public int getNamingLazyObjectSize(Class cls) {
- Session session = getSessionFactory().openSession();
- int rc = 0;
- try {
- Criteria crit = session.createCriteria(cls);
- crit.setProjection(Projections.rowCount());
- List l=crit.list();
- if (l!=null && l.size()>0) {
- Long rc2 = (Long)l.get(0);
- if (rc2 != null)
- rc = rc2.intValue();
- return rc;
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- } finally {
- session.close();
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment