4 Replies Latest reply on Nov 1, 2007 2:39 PM by Dmitry Demyankov

    updating dynamically date in calendar

    Marcelo Krebber Newbie

      hi,

      updating the calendar dynamically seems not to work as expected. the displayed date always the one at creation time. a reRender refuses to change the displayed date programatically.

      see the sample code:

      ..
       <td>
       <h:selectOneMenu styleClass="blabla" value="#{mybean.option}">
       <f:selectItems value="#{mybean.values}" />
       <a4j:support ajaxSingle="true" event="onchange" reRender="id_calendar" />
       </h:selectOneMenu>
       </td>
      
       <td>
       <rich:calendar id="id_calendar" popup="true"
       disabled="#{mybean.option != 'hide'}" value="#{mybean.date}"
       datePattern="dd.MM.yyyy">
       <f:facet name="footer" rendered="false">
       <verbatim />
       </f:facet>
       </rich:calendar>
       </td>
       ..
      


      the point is that althoung mybean.getDate() returns an updated date value, it gets never picked up by the calendar component.

      marcelo

        • 1. Re: updating dynamically date in calendar
          Mo Pour Newbie

          Hi
          I had an issue where, my calendar was not updating my back bean, even though inside an output panel, I had to use ajax support as show below, perhaps you need to do the same thing.

          <rich:calendar id="startDate" inputStyle="width:100px;" datePattern="dd/MM/yyyy" inputType="text" enableManualInput="true" value="#{startDate}" popup="true">
           <a:support event="ondateselected" action="submit()" />
          </rich:calendar>
          


          • 2. Re: updating dynamically date in calendar
            Dmitry Demyankov Novice

            The following code snippet worked fine..

            JSP:

            <h:form>
             <a4j:commandButton id="add_day_btn" value="add day" action="#{testBean.TestMethod}" reRender="panel, calendar"/>
            </h:form>
            
            <h:panelGrid id="panel">
             <h:outputText value="#{testBean.date}"/>
            </h:panelGrid>
            
            <rich:calendar id="calendar" value="#{testBean.date}" popup="true" datePattern="dd.MM.yyyy"/>


            TestBean contains date property with simple get/set methods. Inside TestMethod of TestBean one day is added to the current value of date. Very simple..

            Both panel and rich:calendar are reRendered and correct value of date property is displayed.

            What is the scope of your bean? What exactly are you trying to archive - is it changing currently displayed date in calendar or submitting new date selected in calendar?

            • 3. Re: updating dynamically date in calendar
              Marcelo Krebber Newbie

              yes, im trying smth simple, similar to what you described. a backing bean changes some date thru a widget, an forces thru a reRender the calendar widget to redisplay that date - and that is not happening :-( . the backing bean returns the updated date though, as i can tell from my output log. everything else works just fine. it looked to me as if the calendar refused for ssome reason to update programatically that date.

              im using release 3.1.3. snapshot from about two weeks ago.
              marcelo

              • 4. Re: updating dynamically date in calendar
                Dmitry Demyankov Novice

                My code example worked with 3.1.2GA version. Maybe I'll try it with 3.1.3