Como usar <p:schedule de primefaces con DataClassG
componente schedule primefaces:
Si deseamos crear un schedule para mostrar
Pagina xhtml
<h:form id="formsprintInsert" rendered="#{menuBeans.sprintConsultar}">
<p:dialog visible="true" header="#{mensajes['tabla.Sprint']}" modal="false" closable="true" showEffect="fade" hideEffect="fade" widgetVar="dialog">
<p:ajax event="close" update="growl" listener="#{loginBean.irInicio()}"/>
<p:schedule value="#{scheduleController.lazyEventModel}" />
</p:dialog>
<br />
<p:growl id="growl" life="1500" />
</h:form>
ManagedBeans ScheduleController
Injectamos el sprintData que contiene la lista de sprint y establecemos una hora de inicio.
Named(value = "scheduleController")
@RequestScoped
public class ScheduleController implements Serializable {
@Inject
SprintData sprintData;
private ScheduleModel lazyEventModel;
public ScheduleController() {
lazyEventModel = new LazyScheduleModel() {
@Override
public void loadEvents(Date start, Date end) {
clear();
for (Sprint s : sprintData.getSprintlist()) {
Calendar t = Calendar.getInstance();
t.setTime(s.getFechainicio());
t.set(Calendar.AM_PM, Calendar.PM);
t.set(Calendar.HOUR, 8);
addEvent(new DefaultScheduleEvent(s.getNombre(), t.getTime(), s.getFechaterminacion()));
}
}
};
}
public Date getRandomDate(Date base) {
Calendar date = Calendar.getInstance();
date.setTime(base);
date.add(Calendar.DATE, ((int) (Math.random() * 30)) + 1); //set random day of month
return date.getTime();
}
public Date getRandomFinal(Date base) {
Calendar date = Calendar.getInstance();
date.setTime(base);
date.add(Calendar.DATE, ((int) (Math.random() * 30)) + 10); //set random day of month
return date.getTime();
}
public ScheduleModel getLazyEventModel() {
return lazyEventModel;
}
}
Comments