8 Replies Latest reply on Sep 29, 2009 9:00 AM by asmweb

    rich:calendar does not show the current date

    k_krish_rao

      I have a rich:calendar component where popup is true and uses a calendardata model
      The currentDate attribute is set to a Date attribute in the backing bean

      <rich:calendar id="CalendarID" value="#{calendarBean.selectedDate}" timeZone="#{calendarBean.timeZone}" datePattern="dd-MM-yyyy" showApplyButton="true" popup="true" enableManualInput="true" currentDate="#{calendarBean.startDate}">
      </rich:calendar>


      I have a combo box where the user can select the year. It invokes a method in the backing bean when the year is changed

      <rich:comboBox id="calendarYear" value="#{calendarBean.year}" enableManualInput="false" width="300">
       <a4j:support event="onchange" actionListener="#{calendarBean.yearChanged}" ajaxSingle="true" reRender="CalendarID"/>
       <a4j:support event="onselect" actionListener="#{calendarBean.yearChanged}" ajaxSingle="true" reRender="CalendarID"/>
       <f:selectItems value="#{calendarBean.possibleYears}"/>
      </rich:comboBox>


      public void yearChanged(ActionEvent event)
       {
       Calendar c = Calendar.getInstance();
       c.set(Integer.parseInt(year), Calendar.JANUARY, 01);
       startDate = c.getTime();
       System.out.println("in yearchanged() startDate::"+startDate);
       }


      If 2010 is shown the startDate is set to Jan 01, 2010
      The issue is that when I click on the calendar component it still shows the todays date and not Jan 01, 2010


        • 1. Re: rich:calendar does not show the current date
          ilya_shaikovsky

          Calendar in popup mode opened on today of value is empty by design. this was designed in order to solve next case: the user opens calendar scrolled 100years forward and closes calendar without selection date. calendar should be opened at today again in this case. So in your case the workaround could be - select some default date in needed year in order to open calendar as you need.

          • 2. Re: rich:calendar does not show the current date
            k_krish_rao

            Thanks for the suggestion
            Is there a way for a method that can be invoked in the backing bean class when the user clicks on the calendar component (popup is true).

            Before the calendar is displayed I want a method to be invoked

            • 3. Re: rich:calendar does not show the current date
              k_krish_rao

              If I set a default date in the selected year, for eg I set Jan 01, 2010
              then the issue that i face is when the calendar is popped up I cannot select that date.

              I have developed a oragnizer kind of application simialr to the one in the http://livedemo.exadel.com/richfaces-demo/richfaces/calendar.jsf?c=calendar

              So if I select a date (Sep 20, 2009) so the value attribute is set to a Date attribute in the backing bean
              value="#{Business_BusinessCalendarBean.selectedDate}"
              A ui pops up and I select whether its a holiday or a recurring hoiday. On click of OK, this date is stored in a collection.
              Now if I don not set the selectedDate attribute to null in the backing bean, I cannot select the date again. I have to select on another date, select cancel on the popped ui and then select Sep 20, 2009 again


              • 4. Re: rich:calendar does not show the current date
                ilya_shaikovsky

                first question. unfortunatelly even if you will define support for onshow - request will be fired but the calendar popup will not wait the request completion but will be opened right after request sending. As workaround you could override default behavior by hidding default button for example and adding your own ajax button with the same icon which will send request, call the method you need, reRender the calendar if need, and open calendar with switch method on oncomplete.

                and on the second issue yes you can't select already selected date because event just not fired. you could check the code that workarounds it at the page you mentioned.

                • 5. Re: rich:calendar does not show the current date
                  k_krish_rao

                  Hi,

                  I 'am not too sure what is the work around is in

                  http://livedemo.exadel.com/richfaces-demo/richfaces/calendar.jsf?c=calendar
                  Could you please point out how is it done.

                  I saw that the modal panel pops up when i select a already selected date

                  • 6. Re: rich:calendar does not show the current date
                    k_krish_rao

                    Thanks I saw that in the livedemo organizer application they have done the following

                    <a4j:outputPanel layout="block" id="cell" onclick="#{rich:component('organizer')}.resetSelectedDate()" style="height: 100%;">
                     <h:panelGrid columns="1">
                     <h:outputText value="{day}" style="align:center"/>
                     <h:outputText value="{data.shortDescription.escapeHTML()}"/>
                     <h:outputText value="{data.description.escapeHTML()}"/>
                     </h:panelGrid>
                     </a4j:outputPanel>


                    This is the workaround
                    Have modified my application to have the same changes and it works now
                    Thanks a lot

                    • 7. Re: rich:calendar does not show the current date
                      k_krish_rao

                      I have a new issue after i put in the workaround specified in

                      http://livedemo.exadel.com/richfaces-demo/richfaces/calendar.jsf?c=calendar


                      When a select a date that is already selected the method set to valueChangedListener does not get invoked

                      valueChangeListener="#{Business_BusinessCalendarBean.valueChanged}"

                      How do I force this method to be invoked

                      • 8. [SOLVED] Re: rich:calendar does not show the current date
                        asmweb

                        The problem was on the logic part.... thank you for the help anyway