2 Replies Latest reply on Oct 22, 2007 2:14 PM by Miguel Pinto

    Trying to get date from rich:calendar

    Miguel Pinto Newbie

      I am trying to get the date on a backingBean from a rich:calendar after I hit a h:commandButton.

      It simply isnt working and I couldnt find a solution on foruns or the tutorials. So here is my code:

      jsp:

      <h:panelGroup>
      <h:form id="frmDatePicker">
      <rich:calendar value="#{uidatecontrol.date}" popup="true" id="beginDate" datePattern="dd/M/yyyy"></rich:calendar>
      <h:commandButton value=Update" action="#{uidatecontrol.result}" actionListener="#{uidatecontrol.updateDate}"/>
      </h:form>
      </h:panelGroup>


      Bean:

      public class UIDateControl {
      private Date date=new Date(0);
      private String result;

      public UIDateControl(){
      result="test";
      }
      public String getResult(){
      return result;
      }

      public void setResult(String result){
      this.result=result;
      }
      public Date getDate(){
      return date;
      }

      public void setDate(Date date){
      this.date=date;
      }

      public void updateDate(ActionEvent event){

      result="is it working?";

      }

      }


      I placed breakpoints in all methods. When I start de jsp it calls the constructor...no problem, and then he gets the date from the getDate method.
      When I submit the form the breakpoints in both updateDate and setDate aren't called. It just calls the getDate method.
      WEIRD!!!

      I will need to get the submitted date for several other things in my code. How do i retreive that information in my bean??

      Thanks

        • 1. Re: Trying to get date from rich:calendar
          Ilya Shaikovsky Master

          what is your RF version. Are you checked that your request wasn't break on earlier JSF phases? Use phasetracker to check it.

          • 2. Re: Trying to get date from rich:calendar
            Miguel Pinto Newbie

            I am using the last of Rich Faces versions. Already found the reason for the problem, and I will post here in case somebody else have the same problem.

            On the bean, I was using java.sql.Date to define the date property of the bean. It should be java.util.Date.
            It didnt work with Calendar or String. The only way I found to retrieve the information from the calendar was using java.util.Date as the bean property.

            Hope it helps others...i passed a long time testing until i reached that solution. I think in the rich faces example in the web should have a complete example of the use of a calendar with the bean included. Would have saved me some work.

            Regards,
            Miguel