0
My xhtml is like this:
<p:dataScroller ajax="true" id="listaDiarios"
chunkSize="3" lazy="true"
value="#{managedBeanUsuario.lazyRegistrosDiarios}"
columnClasses="first-letter-page-diary,second-letter-page-diary"
var="registro">
The load I did as follows:
LazyDataModel registros = new LazyDataModel() {
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 the DAO the method is like this:
public static ArrayList 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