0
votes

I have got a p:calendar component inside a p:dialog one. When dialog is shown it takes its value from property in back bean, but when a new date is selected, the SelectEvent arrived to the listener brings the old value and not the new selected date. What is wrong on next code?

   <p:dialog id="eventDialog" widgetVar="eventDialog" header="#{textos.confirmarFechaHora}" showEffect="clip" 
         hideEffect="clip" modal="true"
         appendToBody="true"> <!-- A false, no entran los eventos tras modificar la fecha/hora del calendario --> 
  <h:panelGrid id="eventDetails" columns="2">  
     <h:outputLabel for="calHora" value="#{textos.horaComienzo}" />  
     <p:calendar id="calHora" locale="es" pattern="dd/MM/yyyy HH:mm" 
                 value="#{schedulePFController.fechaComienzo}" mode="inline"
                 required="true"
                 accesskey="true" valueChangeListener="#{schedulePFController.cambiaHoraComienzoVCL}">
        <p:ajax event="dateSelect" listener="#{schedulePFController.cambiaHoraComienzo}"/>
     </p:calendar>
     <p:commandButton value="#{textos.cancelar}" oncomplete="eventDialog.hide();"/>  
     <p:commandButton value="#{textos.mostrarCitas}" 
                      action="#{schedulePFController.verEntradaCalendario}" 
                      rendered="#{schedulePFController.clickedOnCita}"/>
     <p:commandButton value="#{textos.addCita}" 
                      action="#{schedulePFController.addCita}" 
                      rendered="#{!schedulePFController.clickedOnCita}"/>
  </h:panelGrid>

public void cambiaHoraComienzo(SelectEvent ev) {
  Date date = (Date)ev.getObject();
  fechaComienzo = date;
  horaComienzo = new DateCita(date);
  logger.debug("Cambiando fechaComienzo "+horaComienzo.toString()+" +++++++++++++++++++++++++++++++++++++++++");}
4
have you initialized SchedulePFController attribute fechaComienzo with any default value?Freak
oh I just see valueChangeListener="#{schedulePFController.cambiaHoraComienzoVCL}" here you are calling another method and you are looking value in cambiaHoraComienzo method? What are you doing man?Freak
Remove valueChangeListener="#{schedulePFController.cambiaHoraComienzoVCL}" from your p:calender and then check.listener listener="#{schedulePFController.cambiaHoraComienzo}" that you are using in p:ajax tag is enoughFreak
This seems to be a problem with older versions of PrimeFaces. This has been fixed in PrimeFaces 3.3 or 3.3.1. Try to upgrade to a newer version.Lal
I have the same problem and I can't upgrade a big project...user3402040

4 Answers

0
votes

I dont know why you are using valueChangeListener="#{schedulePFController.cambiaHoraComienzoVCL}" in p:calender when you are already invoking a listner in your ajax call.
Just remove valueChangeListener="#{schedulePFController.cambiaHoraComienzoVCL}" from your p:calender and then check.listener listener="#{schedulePFController.cambiaHoraComienzo}" that you are using in p:ajax tag is enough

0
votes

You are doing this the wrong way, to complicated.

Take a look here:

        <p:calendar value="#{ivkDaten.beginn}" locale="de" lang="de"
            pattern="dd.MM.yyyy" label="#{messages['services.ivk.beginn']}:" 
            width="80" id="ivkbeginn" effect="fadeIn" readonlyInput="true" disabled="true"
            showOn="button" mindate="#{services.minDate}" maxdate="#{services.maxDate}">

            <p:ajax event="dateSelect" listener="#{ivkDaten.recalcDate()}"
                update="ablauf" />
        </p:calendar>

You need to set getter/setter for beginn and when you call the method "reclacDate()" you can use beginn and i'm pretty sure you will have the new date.

-1
votes

This seems to be a problem with older versions of PrimeFaces. This has been fixed in PrimeFaces 3.3 or 3.3.1. Try to upgrade to a newer version.

-1
votes

This p:calendar is inside a h:form?

We had the exact same problem and noted that we had forget this