我的xhtml页面中有两个<p:calendar>
组件和timeOnly='true'
属性,我需要验证组件。如果我选择第一次作为上午9:00,第二个组件需要grather(上午10:00)所以我使用更新第二个组件的<p:ajax>
,但我不知道为什么事件没有用,我尝试使用dateSelec
,blur
和change
,但只适用于blur
但不是第一次,而不是我需要的。
这是我的xhtml
<p:dialog id="dlNuevo" widgetVar="agregarOferta" header="Nueva oferta" modal="true" resizable="false" appendTo="@(body)" closable="false">
<h:form id="nuevoHorarioForm">
<p:outputPanel id="nuevoPanel">
<h:panelGrid columns="2" id="nuevoGrid">
<h:outputLabel value="Hora inicio" for="calendarInicio"/>
<p:calendar id="calendarInicio" widgetVar="horaInicioSpin" value="#{hbean.horaInicial}" timeOnly="true" pattern="HH:mm a">
<p:ajax process="@this" event="blur" update="finCal"/>
</p:calendar>
<h:outputLabel value="Hora final" for="finCal"/>
<p:calendar id="finCal" widgetVar="calendarFin" value="#{hbean.horaFinal}" minHour="#{hbean.horaInicial.hours}"
timeOnly="true" pattern="HH:mm a"/>
<h:outputLabel value="Días"/>
<p:selectManyCheckbox layout="pageDirection" value="#{hbean.diasLista}" >
<f:selectItems value="#{hbean.enumeradorDias}" var="dias" itemLabel="#{dias.getLongName( facesContext.viewRoot.locale )}"/>
</p:selectManyCheckbox>
<p:commandButton value="Guardar" actionListener="#{hbean.guardarHora(hbean.horaInicial, hbean.horaFinal)}" oncomplete="PF('agregarOferta').hide()"
update=":formTable:ofertasTBL nuevoHorarioForm :mensajesOfertas"/>
<p:commandButton value="Cancelar" onclick="PF('agregarOferta').hide()">
</p:commandButton>
</h:panelGrid>
</p:outputPanel>
</h:form>
</p:dialog>
这是我的豆子
@ManagedBean(name = "hbean")
@ViewScoped
public class
HorariosOfertasBean extends SICEAbstractBean {
private List<HorariosOfertados> horariosOferta;
private HorariosOfertados horarioSeleccionado;
private HorariosOfertados horarioItem;
private Date horaFinal;
private Date horaInicial;
private Days[] diasLista;
FacesMessage message = null;
FacesContext currentInstance;
FacesResourceUtil facesResouces;
public Days[] getDiasLista() {
return diasLista;
}
public void setDiasLista(Days[] diasLista) {
this.diasLista = diasLista;
}
public List<HorariosOfertados> getHorariosOferta() {
return horariosOferta;
}
public void setHorariosOferta(List<HorariosOfertados> horariosOferta) {
this.horariosOferta = horariosOferta;
}
public Date getHoraFinal() {
return horaFinal;
}
public void setHoraFinal(Date horaFinal) {
this.horaFinal = horaFinal;
}
public Date getHoraInicial() {
return horaInicial;
}
public void setHoraInicial(Date horaInicial) {
this.horaInicial = horaInicial;
}
public HorariosOfertados getHorarioSeleccionado() {
return horarioSeleccionado;
}
public void setHorarioSeleccionado(HorariosOfertados horarioSeleccionado) {
this.horarioSeleccionado = horarioSeleccionado;
}
public HorariosOfertados getHorarioItem() {
return horarioItem;
}
public void setHorarioItem(HorariosOfertados horarioItem) {
this.horarioItem = horarioItem;
}
public Days[] getEnumeradorDias() {
return Days.values();
}
public void convertTime(XMLGregorianCalendar principio, XMLGregorianCalendar ultimo){
horaInicial = principio.toGregorianCalendar().getTime();
horaFinal = ultimo.toGregorianCalendar().getTime();
}
public void convertDays(ListaDiasType valor){
if(valor != null && valor.getDias() != null){
diasLista = new Days[valor.getDias().size()];
for(int i=0;i<valor.getDias().size();i++){
diasLista[i] = Days.valueOf(valor.getDias().get(i).intValue());
}
}
}
public void editarForm(){
convertTime(getHorarioSeleccionado().getHoraInicio(), getHorarioSeleccionado().getHoraFin());
convertDays(getHorarioSeleccionado().getDias());
}
@PostConstruct
public void init() {
facesResouces = new FacesResourceUtil("mx.edu.uteq.sice.core.resources.OfertasMessages", false);
horarioSeleccionado = new HorariosOfertados();
horarioItem = new HorariosOfertados();
setHorariosOferta(getService().getCommonWebServicePort().getHorariosOfertados());
}
public void guardarHora(Date hInicio, Date hFin) throws DatatypeConfigurationException, EntityConstraintException_Exception, EntitySQLException_Exception {
Organizaciones org = new Organizaciones();
Short org2 = 2;
org.setIdOrganizacion(org2);
horarioItem.setIdOrganizacion(org);
GregorianCalendar gcini = new GregorianCalendar();
gcini.setTime(hInicio);
GregorianCalendar gcfin = new GregorianCalendar();
gcfin.setTime(hFin);
XMLGregorianCalendar xmlInicio = DatatypeFactory.newInstance().newXMLGregorianCalendar(gcini);
XMLGregorianCalendar xmlFin = DatatypeFactory.newInstance().newXMLGregorianCalendar(gcfin);
ListaDiasType listaDiasType = new ListaDiasType();
for (Days diasLista1 : diasLista) {
listaDiasType.getDias().add(BigDecimal.valueOf(Days.valueOf(diasLista1.name()).getDayOfWeekValue()));
}
horarioItem.setDias(listaDiasType);
horarioItem.setHoraInicio(xmlInicio);
horarioItem.setHoraFin(xmlFin);
horarioItem = getService().getCommonWebServicePort().insertHorariosOferta(getHorarioItem());
getHorariosOferta().add(horarioItem);
message = new FacesMessage(FacesMessage.SEVERITY_INFO, facesResouces.getString("offerSchedule.add"), "Operación Exitosa");
currentInstance = FacesContext.getCurrentInstance();
currentInstance.addMessage(null, message);
setHorarioItem(new HorariosOfertados());
}
这是组件的功能。
我真的需要帮助来解决为什么会发生这种情况。提前谢谢。
答案 0 :(得分:0)
如果你想在pf:calender中使用更改事件,你必须在pf:ajax的地方使用f:ajax,如果你正在使用pf:ajax dateSelect事件,那么你在监听器方法中使用DateSelectEvent吗?
public void myMethod(DateSelectEvent event)