package managedbean.visit; import java.io.Serializable; import java.util.Date; import java.util.List; import java.util.Map; import javax.annotation.PostConstruct; import javax.faces.view.ViewScoped; import javax.inject.Named; import org.primefaces.model.LazyDataModel; import org.primefaces.model.SortOrder; import TO.VisitTO; import managedbean.common.ManagedBeanBase; import managedbean.common.SessionUtils; @Named("VisitList") @ViewScoped public class VisitListMBean extends ManagedBeanBase implements Serializable { private static final long serialVersionUID = 1L; private int familyDoctorId; private String familyDoctorDisplayName; private LazyDataModel lazyDataModelVisitList; private Date selectedDate; public VisitListMBean() { } @PostConstruct public void init() { // El usuario actual es un medico de familia, recuperamos su Id de la sessión actual this.familyDoctorId = Integer.valueOf(SessionUtils.getUserId()); this.familyDoctorDisplayName = SessionUtils.getUserDisplayName(); this.selectedDate = new Date(); this.lazyDataModelVisitList = new LazyDataModel() { private static final long serialVersionUID = 1L; @Override public List load(int first, int pageSize, String sortField, SortOrder sortOrder, Map filters) { Long totalRowCount = getRemoteManagerVisit().getScheduledVisitsCount(familyDoctorId, selectedDate); this.setRowCount(totalRowCount.intValue()); return getRemoteManagerVisit().listAllScheduledVisitsPaged(familyDoctorId, selectedDate, (first / pageSize), pageSize); } }; } public LazyDataModel getLazyDataModelVisitList() { return lazyDataModelVisitList; } public void showData() { } public Date getSelectedDate() { return selectedDate; } public void setSelectedDate(Date selectedDate) { this.selectedDate = selectedDate; } public String getFamilyDoctorDisplayName() { return familyDoctorDisplayName; } }