1 Reply Latest reply on May 6, 2009 5:32 PM by Nick Belaevski

    rich:calendar and timestamp values

    Craig Hollinshead Newbie

      I have a newbie-ish question on formatting data from rich:calendar. I need to convert the calendar date into a java.sql.Timestamp value for persistence into a database. The calendar is part of a larger form, and I've run into problems saving the date value when submitting the form data.

      I've fixed the problem with the change listener, but the listener persists the data immediately.

      Calendar:

      <rich:calendar id="talkstart"
       value="#{TalkInfoBean.talkstart}"
       popup="true"
       datePattern="yyyy-MM-dd HH:mm"
       valueChangeListener="#{TalkInfoBean.updateTalkStart}"
       showWeeksBar="false"
       showApplyButton="true">
      
       <a4j:support event="onchanged" />
      </rich:calendar>
      


      Change listener function:

      public void updateTalkStart(ValueChangeEvent e)
      {
       Date newdate = (Date) e.getNewValue();
       Timestamp t = new Timestamp(newdate.getTime());
      
       this.setTalkstart(t);
      }
      


      What I would rather do is persist it on submittal of the larger form. My question is, should I do this with a converter, or is there some other way of doing this that I'm missing?