1 Reply Latest reply on Jun 21, 2013 6:01 PM by bleathem

    Updating time on changing dates in rich:calendar in RF4

    piyush.mnnit

      I want to update time to current time on changing dates in rich:calendar in RF4. But it changes to 12:00:00 everytime.   Any suggestion how to get current time in defaultTime attribute?

       

      <c:set var="today" value="new Date()" />

       

                                  <rich:calendar

                                      value="#{TViewerGui.requestParameters.startDate}"

                                      required="true"

                                      readonly="#{TViewerGui.narrowSearchMode}"

                                      disabled="#{TViewerGui.narrowSearchMode}"

                                      id="calFrom"

                                      popup="true"

                                      datePattern="#{datePrefrences.shortDateFormat}"           

                                      showApplyButton="true"

                                      showWeeksBar="false"

                                      boundaryDatesMode="select"

                                      enableManualInput="true"

                                      defaultTime = "#{today}"

                                      resetTimeOnDateSelect = "true"

                                      onclean="var cal=RichFaces.$('#{rich:clientId('calFrom')}');cal.setValue(new Date());">

                                          <a4j:ajax  event="change"

                                          bypassUpdates="false" action="#{TViewerGui.validateForm()}" />

                                      </rich:calendar>

        • 1. Re: Updating time on changing dates in rich:calendar in RF4
          bleathem

          You can do this in javascript, create an ondateselect=updateTime javascript listener that calls the following function:

           

          var updateTime = function() {
               var now = new Date();
               RichFaces.getDomElement('j_idt934:calendar' + 'TimeHours').value = now.getHours()
               RichFaces.getDomElement('j_idt934:calendar' + 'TimeMinutes').value = now.getMinutes()
               RichFaces.$('j_idt934:calendar').hideTimeEditor(true);
               RichFaces.$('j_idt934:calendar').close(true);
          }
          

           

          I realize the above is a poor javascript API.  This is something we are aiming to correct with the RichFaces standalone javascript widgets in RichFaces 5.