7 Replies Latest reply on May 15, 2010 7:45 AM by ilya_shaikovsky

    how can I get the updated date in my rich:calendar?

    markrich

      hi theres,

      I got a problem for the rich:calendar. here is my purpose:
      I want the rerender the output text to display the new updated date once I pick up the date in the rich:calender.

      and here is my codes:

      <h:outputText value="#{timer.time}" id="cal_value" />

      <rich:calendar value="#{timer.time}" popup="true" datePattern="MM/dd/yyyy, HH:mm" enableManualInput="true" >
      <a4j:support event="oninputchange" reRender="cal_value"></a4j:support>
      <a4j:support event="ondateselected" reRender="cal_value"></a4j:support>
      </rich:calendar>

      it can run without any error, but the output text was updated does not my expected. Now the output text will be rerender to privious selected date. for example, I pick up the date as Jul 4, 2008, the output text will not be reRender, and when will pickup another date Jul 7, 2008, the output text will be rerender now but display as Jul 4, 2008 instead what I select just moment.

      did anybody can tell me why? Thx in advance.

        • 1. Re: how can I get the updated date in my rich:calendar?
          chamika

          Actually U can do this from client side. Using java script timer.

          form.cal_value.value = $('calenderID').component.getSelectedDate();
          


          • 2. Re: how can I get the updated date in my rich:calendar?
            ilya_shaikovsky

            use onchanged instead of ondateselected. this change was described in our docs.

            • 3. Re: how can I get the updated date in my rich:calendar?
              markrich

              Thx your advise, ilya_shaikovsky.

              it's okay now.

              • 4. Re: how can I get the updated date in my rich:calendar?
                lenyas66

                Hi Ilya,

                 

                I noticed some problem with the way rich:calendar reacts to manual editing of this field.

                 

                Let's say, I selected the value "Mar-31-2010" from the calendar and it appears as the value.

                 

                If I reference it from JavaScript as follows:

                 

                var pubDate = ${rich:component('publishedDate')}.getSelectedDate();

                 

                It works just fine.

                 

                But, if I manually delete the value, so that calendar field appears empty, calling previous method returns old value!

                 

                Strange thing is that after I call it second time, it realizes that value has changed and works fine.

                 

                Note, that JavaScript function is triggered by the click of the button. So, it seems that calendar component is not reacting to the editing before clicking occurs first time.

                 

                Any suggestions?

                 

                Please see the code for calendar below.

                 

                <

                 

                rich:calendar id="publishedDate" value="#{piPublisherBean.publishDate}" datePattern="MM/dd/yyyy" popup="true"

                 

                cellWidth="24px" cellHeight="22px" enableManualInput="true">

                 

                <f:facet name="header">

                 

                <h:panelGrid columns="2" width="100%">

                 

                <h:outputText value="{selectedDateControl}" />

                 

                <h:outputText value="{todayControl}" />

                 

                </h:panelGrid>

                 

                </f:facet>

                 

                <f:facet name="weekDay">

                 

                <h:panelGroup>

                 

                <h:outputText value="{weekDayLabelShort}" />

                 

                </h:panelGroup>

                 

                </f:facet>

                 

                <f:facet name="footer">

                 

                <h:panelGrid columns="3" width="100%">

                 

                <h:outputText value="{previousMonthControl}" />

                 

                <h:outputText value="{currentMonthControl}" />

                 

                <h:outputText value="{nextMonthControl}" />

                 

                </h:panelGrid>

                 

                </f:facet>

                 

                <h:outputText value="{day}"></h:outputText>

                 

                <rich:beanValidator summary="Invalid date" />

                 

                </rich:calendar>

                • 5. Re: how can I get the updated date in my rich:calendar?
                  ilya_shaikovsky

                  yes, selected date object updated only while popup opening (parses input to discplay current) and selecting from popup(actual selection occurs).. and yes, unfortunatelly seems we lacks function which could read from input and parse according to date. so seems you need to get it from input using it's predefined id. (clientId + InputDate)

                  • 6. Re: how can I get the updated date in my rich:calendar?
                    lenyas66

                    So, if the client Id is "publishedDate" in my example, you suggest to use something like that;

                     

                    getElementById('publishedDateInputDate').value

                     

                    Would is still be date or just a string?

                     

                    On somewhat unrelated note, how do I disable showing week numbers in popup calendar? I didn't mention them in my calendar definition, but they are still showing by default.

                    • 7. Re: how can I get the updated date in my rich:calendar?
                      ilya_shaikovsky

                      1) string

                       

                      2)showWeeksBar