7 Replies Latest reply on Feb 2, 2010 5:21 AM by faffinito

    rich:calendar and refresh default value

      Hi all,

      I have a rich calendar in a modal panel. When I use the popup calendar the first time, the default values (month and year) are the current ones. Let's suppose I select a date, for example June 30, 1977. I insert this date in my panel and I go on. When I return to the calendar to insert a new date, I find as default value June 1977. How can I cancel the memory of the last inserted date? Or, alternatively, how can I set a default value for every time I open the calendar?

       

      this is my code:

       

      <a:region>

      <rich:calendar id="onsetDatetimeUpdated"

      required="true"

      value="#{diseaseAction.bufferDisease.onsetDate}"

      datePattern="dd/MM/yyyy"

      enableManualInput="true"

      rendered="#{!diseaseAction.updateMode.equals('delete')}">

      <a:support event="onblur" reRender="onsetDatetimeUpdated" ajaxSingle="true" />

      </rich:calendar>

      </a:region>

       

      Thanks in advance

       

      Fabio

        • 1. Re: rich:calendar and refresh default value
          ilya_shaikovsky
          you could either reRender it with initial value or call js api function and set the date.
          • 2. Re: rich:calendar and refresh default value

            Thanks!

            The unresolved issue is WHERE to put the reRender instruction. Should I put it on the link that opens the modal panel? Or elsewhere?

            • 3. Re: rich:calendar and refresh default value
              ilya_shaikovsky
              If you choosing ajax and already using a link to show modal panel - you should point calendar to be reRendered from this link before panel wil be shown at oncomplete.
              • 4. Re: rich:calendar and refresh default value

                I followed your suggestion, but that didn't worked.

                I insert some of my code to clarify, hoping it helps!

                 

                Thank you!

                 

                 

                This is where the modal panel is called.

                 

                 

                and this is the calendar inside my modal panel:

                 

                 

                • 5. Re: rich:calendar and refresh default value

                  Maybe I have some problem with this editor too...

                   

                  this is the place where the panel is linked:

                   

                  <a4j:commandLink id="addDiseaselink" ajaxSingle="true" value="#{currentVisit.diseases.size()>0 ? 'Aggiungi Diagnosi' : 'Diagnosi'}"

                                                     reRender="diseasePanel, onsetDatetimeUpdated" action="#{diseaseAction.initDisease}"

                                                     oncomplete="#{rich:component('updateDisease')}.show()"

                                                     rendered="#{identity.hasRole('2') and !currentVisit.visitStatus.tag.equals('locked')}"

                                                     style="font-weight: bold; font-size: 14px; line-height: 28px; margin-left: 30px">

                            <f:setPropertyActionListener value="add" target="#{diseaseAction.updateMode}" />

                  </a4j:commandLink>

                   

                  and this is the modal panel:

                   

                  <s:decorate id="onsetDatetimeField"

                                      template="../layout/edit.xhtml"

                                      styleClass="visit-field">

                   

                                      <ui:define name="label">Data insorgenza </ui:define>

                   

                   

                                      <h:outputText  value="#{diseaseAction.bufferDisease.onsetDate}"

                                                               rendered="#{diseaseAction.updateMode.equals('delete') or diseaseAction.updateMode.equals('read')}"

                                                               style="font-weight:bold;font-size:12px" datePattern="dd/MM/yyyy"/>

                   

                   

                                       <a:region>

                                           <rich:calendar id="onsetDatetimeUpdated"

                                                                    required="true"

                                                                    value="#{diseaseAction.bufferDisease.onsetDate}"

                                                                    datePattern="dd/MM/yyyy"

                                                                    enableManualInput="true"

                                                                    rendered="#{not (diseaseAction.updateMode.equals('delete') or                                                                            diseaseAction.updateMode.equals('read'))}">

                                                <a:support event="onblur" reRender="onsetDatetimeUpdated" ajaxSingle="true" />

                                           </rich:calendar>

                                      </a:region>

                  </s:decorate>

                   

                  I would think that it could be a problem related to the instance, more than to a refreshing of the calendar. Probably the calendar redisplay the value contained in the #{diseaseAction.bufferDisease.onsetDate} stored in the current instance. Is that possible?

                   

                  Thanks again.

                   

                  • 6. Re: rich:calendar and refresh default value
                    ilya_shaikovsky
                    sure if the #{diseaseAction.bufferDisease.onsetDate} contains some date - it will be set as current.
                    • 7. Re: rich:calendar and refresh default value

                      Same behavior even if such value is null. I think that I've got the answer here :

                      https://jira.jboss.org/jira/browse/RF-5211