4 Replies Latest reply on May 28, 2007 8:07 AM by Damian Harvey

    s:selectDate ajaxRender

    Venkatesh BR Newbie

      Noticed a few problems with s:selectDate when it is rendered through ajax.
      i have the following code

      <a4j:outputPanel id="details">
      <h:inputText id="regDate" <s:convertDateTime pattern="dd/MM/yyyy" /> </h:inputText>
      <s:selectDate id="selectRegDate" for="regDate" dateFormat="dd/MM/yyyy">
       <h:graphicImage url="/images/dtpick.gif" style="margin-left:5px;cursor:pointer" />
      </s:selectDate>
      </a4j:outputPanel>
      


      When the outputPanel is rendered using an event from other component with the following code.
      <a4j:support event="onchange" reRender="details">


      The dateformat sometimes defaults to MM/dd/yyyy.

      and also the selectdate component does not generate any events for validation. i.e i cannot have a4j:support for ajax invocation inside h:inputText

        • 1. Re: s:selectDate ajaxRender
          Venkatesh BR Newbie

          when i changed the dateformat in calendar.js
          var CAL_DATE_FORMAT = "dd/mm/yyyy"; then the date format seems to be working fine.

          But no java scripting events like onchange and onblur are generated on the inputtext component after selecting the date.

          • 2. Re: s:selectDate ajaxRender
            Bram Biesbrouck Newbie

            Same problem here...

            • 4. Re: s:selectDate ajaxRender
              Damian Harvey Master

              I had the same issue today. Using the magic of FireBug you can see that when the date is rendered normally (ie. not via AJAX) it includes a portion of javascript as per below that sets your defaults from the selectDate:

              <script type="text/javascript">
              var CAL_DAYS_SHORT = 'Su,Mo,Tu,We,Th,Fr,Sa';
              var CAL_DAYS_MEDIUM = 'Sun,Mon,Tue,Wed,Thu,Fri,Sat';
              var CAL_DAYS_LONG = 'Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday';
              var CAL_MONTHS_MEDIUM = 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec';
              var CAL_MONTHS_LONG = 'January,February,March,April,May,June,July,August,September,October,November,December';
              var CAL_FIRST_DAY_OF_WEEK = 0;
              var CAL_DATE_FORMAT = 'dd/MM/yyyy';
              </script>

              When the date is rendered via AJAX it isn't a new page load so that portion isn't called, so CAL_DATE_FORMAT is undefined and the date is defaulted to MM/dd/yyyy as per line 12 of calendar.js.

              The workaround is to add this block into your page (anywhere really) so CAL_DATE_FORMAT is set before the date is rendered via AJAX. Works for me anyway.

              Cheers,

              Damian