1 Reply Latest reply on Aug 27, 2009 2:46 AM by David Coleman

    rich:calendar doesn't work with joda DateTime

    austral austral Newbie

      Hi !

      I use the JSF framework for my application, and the rich faces library for many components.

      But for the rich:calendar, when I load a data from the database (joda DateTime) to render it into the component, the following error appears :

      javax.faces.FacesException: Wrong attibute type or there is no converter for custom attibute type at org.richfaces.component.UICalendar.getAsDate(UICalendar.java:335)

      I put a converter which converts the DateTime into String for the rendering but it appears that it isn't used. In debug mode, there is no passage in the method of my converter. I think the component uses its converter and uses a Date. So my DateTime is not recognized.

      But when the value to render is empty in my database, the component is rendered normally. And then, when I put a value with the calendar and I submit the form, the value is put in the database as it should work, my converter which transforms the String into a DateTime is used and works normally.

      So, how can I load my data in format joda DateTime ? I just want to precise that I use the patterns correctly (dd/MM/yyyy HH:mm).

      If someone has an answer for me, it could be great !

      Regards,

      Austral.

        • 1. Re: rich:calendar doesn't work with joda DateTime
          David Coleman Newbie

          Hi Austral,

          I found this link http://www.jroller.com/ThoughtPark/entry/facelets_and_joda_time very beneficial, it explains how to integrete an Joda DateTime converter thats freely available on the internet very well.

          However, I did have problems integrating the Joda DateTimeConverter with the rich:calendar but after doing some debugging, I discovered the problem. The attribute 'datePattern' on rich:calender only formats the string on the client site; it does not call 'customConvert.setPattern' on the date time converter, therefore, the front-end and back-end date formats were incompatible.

          I ended up getting it to work by specifying the 'datePattern'in both the calendar and the converter as follows:

          <rich:calendar value="#{searchEntry.dateOfBirth}" datePattern='yyyy-MM-dd H:mm'>
           <joda:convertDateTime type='both' pattern='yyyy-MM-dd H:mm'/>
          </rich:calendar>
          

          Regards
          Dave