1
Guys, I started using dataScroller today with Lazy of the first faces
<p:dataScroller ajax="true" id="listaDiarios"
chunkSize="3" lazy="true"
styleClass='ui-datagrid-no-border'
value="#{managedBeanUsuario.lazyRegistrosDiarios}"
var="registro">
The load I did as follows:
LazyDataModel<RegistroDiario> registros = new LazyDataModel<RegistroDiario>() {
private static final long serialVersionUID = -4742720028771554420L;
@Override
public List<RegistroDiario> load(int first, int pageSize,
String sortField, SortOrder sortOrder,
Map<String, Object> filters) {
// TODO Auto-generated method stub
System.out.println("entrei load "+ first);
System.out.println("entrei size "+ pageSize);
System.out.println("qnt linhas "+ this.getRowCount());
return RegistroDiarioDao.getAllLastRegistroDiarioVelho(first);
}
};
And in DAO the method is like this:
public static ArrayList<RegistroDiario> getAllLastRegistroDiarioVelho(int inicio) {
EntityManager em = HibernateManageFactory.getFactory()
.createEntityManager();
Query query = em.createQuery(
"select u from RegistroDiario u order by u.dtRegistro desc",
RegistroDiario.class);
query.setMaxResults(3);
query.setFirstResult(inicio);
@SuppressWarnings("unchecked")
ArrayList<RegistroDiario> registrosDiarios = (ArrayList<RegistroDiario>) query.getResultList();
em.close();
return registrosDiarios;
}
He brings the records, so far so good.
I want him to always bring 3-3, the first time he brings 3, when he gives the scroll bar, he brings 3 more and then he stops to go get more records. Being that I have much more than 6 records in the bank.
I don’t know if I’m doing it right or wrong, so I wanted your help, I want him to bring all the bank records, but going 3 by 3