4 Replies Latest reply on Feb 14, 2012 10:21 AM by dustedrob

    rich:calendar value is one step behind

    dustedrob

      Hi,

      richfaces noob here.  Im using RichFaces 4.1.

      Within my .xhtml i have defined a rich:calendar component like this:

       

       

      <h:outputLabel value="#{bundle.CreateSolicitudesLabel_fechafinal}" for="fechafinal" />
                          <rich:calendar locale="es_MX" id="fechafinal" valueChangeListener="#{solicitudesBean.fechaValueChangeListener(event)}" value="#{solicitudesBean.solicitud.fechafinal}" datePattern="dd/MM/yyyy" required="true" requiredMessage="#{bundle.CreateSolicitudesRequiredMessage_fechafinal}">
                              <a4j:ajax/>
                          </rich:calendar>
      

       

      And my backing bean for the valueChangeListener:

       

       


      public void fechaValueChangeListener(ValueChangeEvent event)

      {



      System.out.println("FECHA FINAL"+solicitud.getFechafinal());

      }

       

       

      The problem is that the date value is not set the first time i select a date on the calendar and it will print out a null. On the following attempts, the date value will always be one step behind the currently selected value.

      What am i doing wrong?

      Thanks for your help

        • 1. Re: rich:calendar value is one step behind
          pvito

          Hi, Roberto

           

          You should use event.getNewValue() for getting selected value:

           

          public void fechaValueChangeListener(ValueChangeEvent event){

                   System.out.println("FECHA FINAL"+ event.getNewValue());

          }

           

           

          Regards, Vitaliy

          • 2. Re: rich:calendar value is one step behind
            dustedrob

            I just tried that and it throws a NullPointerException:

             

            javax.faces.event.AbortProcessingException: /home/solicitudes/Create.xhtml @39,301 valueChangeListener="#{solicitudesBean.fechaValueChangeListener(event)}": java.lang.NullPointerException

                at javax.faces.event.MethodExpressionValueChangeListener.processValueChange(MethodExpressionValueChangeListener.java:157)

                at javax.faces.event.ValueChangeEvent.processListener(ValueChangeEvent.java:134)

                at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)

                at org.richfaces.component.AbstractCalendar.broadcast(AbstractCalendar.java:359)

                at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:759)

                at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1174)

                at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)

                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

                at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

                at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

                at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)

                at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)

                at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)

                at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)

                at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)

                at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)

                at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)

                at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)

                at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)

                at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)

                at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)

                at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)

                at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)

                at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)

                at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)

                at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)

                at com.sun.grizzly.ContextTask.run(ContextTask.java:71)

                at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)

                at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)

            • 3. Re: rich:calendar value is one step behind
              pvito

              Try remove (event) from #{solicitudesBean.fechaValueChangeListener(event)

               

              It's work for me:

               

               

              <h:form>

                  <rich:calendar locale="es_MX" id="fechafinal"

                                 valueChangeListener="#{bean.fechaValueChangeListener}"

                                 value="#{bean.fechafinal}"

                                 datePattern="dd/MM/yyyy" required="true">

                      <a4j:ajax/>

                  </rich:calendar>

              </h:form>

              public void fechaValueChangeListener(ValueChangeEvent event){

                       System.out.println("FECHA FINAL"+ event.getNewValue());

              }

               

              Regards, Vitaliy

              • 4. Re: rich:calendar value is one step behind
                dustedrob

                I just tried that as well and it doesn't do anything. I'm using JSF 2.1 which i belive forces you to mark the parameters in the expression...