Ejemplo de paginación (Listado de preguntas pendientes) con primefaces

utilizando LazyDataModel, con recarga automática de la página
solicitada.
This commit is contained in:
Marcos Garcia Nuñez
2019-12-16 22:02:27 +01:00
parent dcbebe5253
commit 9bfdebbea4
12 changed files with 250 additions and 54 deletions

View File

@@ -6,21 +6,20 @@ import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import org.jboss.security.auth.spi.Users.User;
import TO.FamilyDoctorTO;
import TO.MedicalSpecialtyTO;
import TO.PatientTO;
import TO.PrimaryHealthCareCenterTO;
import TO.QuestionTO;
import TO.SpecialistDoctorTO;
import common.Utils;
import jpa.FamilyDoctorJPA;
import jpa.MedicalSpecialtyJPA;
import jpa.PatientJPA;
import jpa.PrimaryHealthCareCenterJPA;
import jpa.QuestionJPA;
import jpa.SpecialistDoctorJPA;
@Stateless
@@ -311,4 +310,24 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
else
return null;
}
public QuestionTO getPOJOforQuestionJPA(QuestionJPA qs, int nestedProps) {
QuestionTO qsTO = null;
if (qs != null) {
FamilyDoctorJPA fd = null;
PatientJPA pat = null;
if (nestedProps > 0) {
fd = qs.getFamilyDoctor();
pat = qs.getPatient();
}
nestedProps--;
qsTO = new QuestionTO(qs.getId(), qs.getTitle(), qs.getMessage(), qs.getStatus(), this.getPOJOforPatientJPA(pat, nestedProps),
this.getPOJOforFamilyDoctorJPA(fd, nestedProps), qs.getResponse());
}
return qsTO;
}
}

View File

@@ -1,6 +1,5 @@
package ejb.common;
import java.util.Collection;
import java.util.List;
import javax.ejb.Local;
@@ -9,11 +8,13 @@ import TO.FamilyDoctorTO;
import TO.MedicalSpecialtyTO;
import TO.PatientTO;
import TO.PrimaryHealthCareCenterTO;
import TO.QuestionTO;
import TO.SpecialistDoctorTO;
import jpa.FamilyDoctorJPA;
import jpa.MedicalSpecialtyJPA;
import jpa.PatientJPA;
import jpa.PrimaryHealthCareCenterJPA;
import jpa.QuestionJPA;
import jpa.SpecialistDoctorJPA;
/**
@@ -70,4 +71,5 @@ public interface CommonFacadeLocal {
public PatientTO getPOJOforPatientJPA(PatientJPA pat, int nestedProps);
public QuestionTO getPOJOforQuestionJPA(QuestionJPA qs, int nestedProps);
}