1 2 Previous Next 24 Replies Latest reply on Apr 9, 2008 9:55 AM by jamesjmp

    Calendar what type is the date?

    tony.herstell1

      I have this:

      <rich:calendar id="allocation_calendar" value="#{bookingController.bookingDateRequired}" selectedDate="#{bookingController.bookingDateRequired}">

      Which maps to:

      /**
      * @return the date of the booking (the Booking Day)
      */
      public GregorianCalendar getBookingDateRequired();

      /**
      * @param dateRequired is the date required for the booking
      */
      public void setBookingDateRequired(GregorianCalendar dateRequired);

      but I keep getting


      13:22:56,578 INFO [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
      sourceId=j_id12:allocation_calendar[severity=(ERROR 2), summary=(/WEB-INF/pages/resourceAvailability/dayView.xhtml @15,151 value="#{bookingController.bookingDateRequired}": Property 'bookingDateRequired' not writable on type java.util.GregorianCalendar), detail=(/WEB-INF/pages/resourceAvailability/dayView.xhtml @15,151 value="#{bookingController.bookingDateRequired}": Property 'bookingDateRequired' not writable on type java.util.GregorianCalendar)]


        • 1. Re: Calendar what type is the date?
          tony.herstell1

          setBookingDayRequired() is not being called.

          • 2. Re: Calendar what type is the date?
            tony.herstell1

            shortened to
            <rich:calendar id="allocation_calendar" value="#{bookingController.bookingDateRequired}">
            <a4j:support event="ondateselected" reRender="allocation_calendar"/>
            </rich:calendar>
            nothing cahnged

            • 3. Re: Calendar what type is the date?
              tony.herstell1

              datePattern="EEEE, dd MMMM yyyy" does not seem to work.

              Initally displays ok with EEEE replaced by day (Tuesday) but after that it just displays EEEE

              and get
              allocation_calendar[severity=(ERROR 2), summary=(j_id12:allocation_calendar: 'EEEE, 14 February 2008' could not be understood as a date.), detail=(j_id12:allocation_calendar: 'EEEE, 14 February 2008' could not be understood as a date. Example: Tuesday, 12 February 2008 )

              • 4. Re: Calendar what type is the date?
                tony.herstell1

                APART from the EEEE problem (and E coincidently) the date picker works fine when <ajax:support> is got rid of.

                Any ideas?

                • 5. Re: Calendar what type is the date?
                  tony.herstell1

                  Works...
                  <rich:calendar id="allocation_calendar" value="#{bookingController.bookingDateRequired}" showApplyButton="true" inputSize="30"> <!-- datePattern="EEEE, dd MMMM yyyy" -->
                  <!-- <a4jx:support event="ondateselected"/> -->
                  </rich:calendar>

                  I will try just adding a new button (for now) that submits the page until someone has any idea why this doesn't work.

                  • 6. Re: Calendar what type is the date?
                    tony.herstell1

                     

                    <rich:calendar id="allocation_calendar" popup="true"
                     currentDate="#{bookingController.bookingDateRequired}"
                     datePattern="dd MMMM yyyy" inputSize="30" immediate="true">
                     <!-- value="#{bookingController.bookingDateRequired}"
                     datePattern="EEEE, dd MMMM yyyy" inputSize="30" -->
                     <a4j:support event="ondateselected"/>
                    </rich:calendar>
                    


                    This works (basically - so apart from the datePattern and the spurious submit on the first date select).

                    The BIG problem seemed to be having value in there.

                    No idea why; but it breaks it.



                    • 7. Re: Calendar what type is the date?
                      tony.herstell1

                      Ok, I am still wasting time on this.
                      It may well report no errors but it wont update the date you selected in the calendar.

                      <rich:calendar id="allocation_calendar" popup="true"
                       currentDate="#{bookingController.bookingDateRequired}"
                       datePattern="dd MMMM yyyy"
                       inputSize="30" immediate="true"> <!-- value="#{bookingController.bookingDateRequired}" datePattern="EEEE, dd MMMM yyyy" inputSize="30" -->
                       <a4j:support event="ondateselected" action="#{bookingController.calendarDateChanged()}"/>
                       </rich:calendar>
                      


                      The "setter" for the date is NOT called.

                      As a work round I can call a routine in the support tag to say its been changed (which works) but I need top know what the variable that holds the date is.

                      Am I the ONLY one having problems with the date picker?

                      • 8. Re: Calendar what type is the date?
                        tony.herstell1

                        I ahve ene played with currentDateChangeListener on the Calendar but that didnt do much either.

                        :(

                        • 9. Re: Calendar what type is the date?
                          daniel.soneira

                          Have you tried changing your GregorianCalendar to Calendar?

                          I'm not sure why you would want to use this specific class in the first place.

                          private Calendar dateRequired;
                          
                          public Calendar getBookingDateRequired();
                          public void setBookingDateRequired(Calendar dateRequired);


                          • 10. Re: Calendar what type is the date?
                            tony.herstell1

                            From the gregorianCalendar javadoc:

                            GregorianCalendar is a concrete subclass of Calendar and provides the standard calendar system used by most of the world.



                            I did change the code over to use Calendar and the calendar still does not work.

                            As Seams Calendar is deprecated AND i wanted this Ajaxed this is a bit of a show stopper.

                            Perhaps someone can copy/paste some code showing it working in Seam.. It can't be that difficult can it?

                            Seam 2.0.1.GA + RF 3.1.4.GA





                            
                            <rich:calendar
                             id="allocation_calendar"
                             popup="true"
                             currentDate="#{bookingController.bookingDateRequired}"
                             datePattern="dd MMMM yyyy"
                             inputSize="30"
                             immediate="true">
                             <!-- value="#{bookingController.bookingDateRequired}" -- Causes weired problems in RichFaces
                             datePattern="EEEE, dd MMMM yyyy" -- Doesnt Work in RichFaces-->
                             <a4j:support event="ondateselected"
                             action="#{bookingController.calendarDateChanged()}"/>
                             <!-- This gets called but never with the updated date -->
                            </rich:calendar>
                            
                            
                             @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
                             public Calendar getBookingDateRequired() {
                             Calendar valueToReturn = null;
                             for (BookingDay eachDay: booking.getBookingDays()) {
                             if (eachDay.getDayNumber() == BOOKING_DAY_NUMBER) {
                             valueToReturn = eachDay.getOnDate();
                             break;
                             }
                             }
                             return valueToReturn;
                             }
                            
                             @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
                             public void setBookingDateRequired(Calendar dateRequired) {
                             log.info(">setBookingDateRequired "+dateRequired);
                             if (dateRequired != null) {
                             for (BookingDay eachDay: booking.getBookingDays()) {
                             if (eachDay.getDayNumber() == BOOKING_DAY_NUMBER) {
                             GregorianCalendar gregorianCalendar = new GregorianCalendar();
                             gregorianCalendar.setTime(dateRequired.getTime());
                             eachDay.setOnDate(gregorianCalendar);
                             break;
                             }
                             }
                             } else {
                             log.error("#setBookingDateRequired > null date supplied.");
                             // Happens a lot in RichFaces don't worry too much about it.
                             }
                             }
                            


                            Cross Posting to Seam Forum also.

                            • 11. Re: Calendar what type is the date?
                              tony.herstell1

                              I have traced as far as I can with the debugger and I seem to need to have the value attribute in the markup; but all I get is :


                              22:30:10,843 INFO [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
                              sourceId=j_id12:allocation_calendar[severity=(ERROR 2), summary=(/WEB-INF/pages/resourceAvailability/dayView.xhtml @17,38 value="#{bookingController.bookingDateRequired}": java.lang.IllegalArgumentException: argument type mismatch), detail=(/WEB-INF/pages/resourceAvailability/dayView.xhtml @17,38 value="#{bookingController.bookingDateRequired}": java.lang.IllegalArgumentException: argument type mismatch)]


                              Still getting no futher with this however... has anyone got Calendar to work with Seam?
                              <rich:calendar value="#{bookingController.bookingDateRequired}" ajaxSingle="true" id="allocation_calendar" popup="true" currentDate="#{bookingController.bookingDateRequired}" datePattern="dd MMMM yyyy" inputSize="30" immediate="true">
                               <!-- value="#{bookingController.bookingDateRequired}" datePattern="EEEE, dd MMMM yyyy" inputSize="30" -->
                               <a4j:support event="ondateselected" action="#{bookingController.calendarDateChanged()}" />
                              </rich:calendar>
                              


                              • 12. Re: Calendar what type is the date?
                                baz

                                 

                                has anyone got Calendar to work with Seam?

                                Yes we are using this in our projects. Seam 2.0.0GA and Richfaces 3.1.4
                                It is fairly useable, but only since rf3.1.4

                                For the type of value:
                                We had the same problem. But we tried java.util.date and it worked.
                                I do not know why they(the implementors) choosed this type....
                                Ciao,
                                Carsten

                                • 13. Re: Calendar what type is the date?
                                  mmichalek

                                  I also recommend trying java.util.Date as the type on your backing component. The rich:calendar allows the user to pick a date which is why it maps to a java.util.Date on the bean.

                                  • 14. Re: Calendar what type is the date?
                                    tony.herstell1

                                    baz and mmichalek... You guys are the best.
                                    You MUST use java.util.Date

                                    For any poor soul following behind.. here is the code snippet:

                                    <rich:calendar value="#{bookingController.bookingDateRequired}"
                                     ajaxSingle="true" id="allocation_calendar" popup="true"
                                     currentDate="#{bookingController.bookingDateRequired}" datePattern="dd MMMM yyyy"inputSize="30" immediate="true">
                                     <a4j:support event="ondateselected" />
                                    </rich:calendar>
                                    


                                    Backing bean:



                                     @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
                                     public Date getBookingDateRequired() {
                                     Calendar valueToReturn = null;
                                     for (BookingDay eachDay: booking.getBookingDays()) {
                                     if (eachDay.getDayNumber() == BOOKING_DAY_NUMBER) {
                                     valueToReturn = eachDay.getOnDate();
                                     break;
                                     }
                                     }
                                     return valueToReturn.getTime();
                                     }
                                    
                                     @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
                                     public void setBookingDateRequired(Date dateRequired) {
                                     log.info(">setBookingDateRequired "+dateRequired);
                                     if (dateRequired != null) {
                                     for (BookingDay eachDay: booking.getBookingDays()) {
                                     if (eachDay.getDayNumber() == BOOKING_DAY_NUMBER) {
                                     GregorianCalendar gregorianCalendar = new GregorianCalendar();
                                     gregorianCalendar.setTime(dateRequired);
                                     eachDay.setOnDate(gregorianCalendar);
                                     break;
                                     }
                                     }
                                     } else {
                                     log.error("#setBookingDateRequired > null date supplied.");
                                     // Usually ignore this if RF as quite common.
                                     }
                                     }
                                    


                                    Would be useful to go into the doco that you have to use java.util.Date.

                                    1 2 Previous Next