1 Reply Latest reply on Dec 31, 2012 10:52 PM by sivaprasad9394

    rich Calendar with Date Range

    guga.java

      Hi to all,

       

      Maybe this topic has already been discussed but I could not find the solution ...

      The question is how to implement a "Date Range" calendar component in the RichFaces like this example http://jqueryui.com/datepicker/ # date-range?

      I select a start date and the next field only let select future dates that date that was selected in the initial field?

       

      i try to use preloadDateRangeBegin but I didn't understand very well how to use CalendarDataModel

        • 1. Re: rich Calendar with Date Range
          sivaprasad9394

          Hello Gustavo,

           

          Please have a look on the below link ,

          http://me-ramesh.blogspot.in/2010/12/rich-faces-calendardatamodel.html

           

          OR

           

          Get the from and to date in the back end bean and do the validation when clicking the save button or submit button.See the bold text.This will help you for the server side properly.

           

            public String ValidateFormFieldsSearchTransaction()

            {

              String action = null;

              try

              {

                if ((this.tnx_StartDate == null) || (this.tnx_StartDate.equals("")))

                {

                  if ((this.tnx_EndDate == null) || (this.tnx_EndDate.equals("")))

                  {

                    action = "success";

                  }

                  else

                  {

                    log.debug("ValidateFormFields:From is null value.");

                    FacesContext faceContext = FacesContext.getCurrentInstance();

                    FacesMessage facesMessage = new FacesMessage();

                    facesMessage.setSeverity(FacesMessage.SEVERITY_ERROR);

                    facesMessage.setDetail(ppsResources.getString("errorSelectFromDate"));

                    facesMessage.setSummary(ppsResources.getString("errorSelectFromDate"));

                    faceContext.addMessage("psInclude:transSearch:SearchForm:selectFromDateField", facesMessage);

                    action = "error";

                  }

                }

           

                if ((this.tnx_StartDate != null) && (this.tnx_EndDate != null))

                {

                  Boolean flagReturn = Boolean.valueOf(DateUtil.isDate1GreaterThanDate2(DateUtil.toString(this.tnx_StartDate, "dd/MM/yyyy HH:mm"), DateUtil.toString(this.tnx_EndDate, "dd/MM/yyyy HH:mm")));

                  if (flagReturn.booleanValue())

                  {

                    log.debug("ValidateFormFields:From is greater than To date.");

                    FacesContext faceContext = FacesContext.getCurrentInstance();

                    FacesMessage facesMessage = new FacesMessage();

                    facesMessage.setSeverity(FacesMessage.SEVERITY_ERROR);

                    facesMessage.setDetail(ppsResources.getString("errorSelectCorrectDate"));

                    facesMessage.setSummary(ppsResources.getString("errorSelectCorrectDate"));

                    faceContext.addMessage("psInclude:transSearch:SearchForm:selectCorrectDateFormatField", facesMessage);

                    action = "error";

                  }

                  else

                  {

                    Boolean flagValue = Boolean.valueOf(DateUtil.isGreaterThanToday(this.tnx_EndDate));

                    log.debug("Flag todategreater:" + flagValue);

                    if (flagValue.booleanValue())

                    {

                      log.debug("ValidateFormFields:TO is greater than Today date.");

                      FacesContext faceContext = FacesContext.getCurrentInstance();

                      FacesMessage facesMessage = new FacesMessage();

                      facesMessage.setSeverity(FacesMessage.SEVERITY_ERROR);

                      facesMessage.setDetail(ppsResources.getString("errorTodategreater"));

                      facesMessage.setSummary(ppsResources.getString("errorTodategreater"));

                      faceContext.addMessage("psInclude:transSearch:SearchForm:selectToDateFormatField", facesMessage);

                      action = "error";

                    }

                    else

                    {

                      action = "success";

                    }

                  }

                }

                if ((this.tnx_StartDate != null) && (this.tnx_EndDate == null))

                {

                  Boolean flagValue = Boolean.valueOf(DateUtil.isGreaterThanToday(this.tnx_StartDate));

                  if (flagValue.booleanValue())

                  {

                    log.debug("ValidateFormFields:TO is greater than Today date.");

                    FacesContext faceContext = FacesContext.getCurrentInstance();

                    FacesMessage facesMessage = new FacesMessage();

                    facesMessage.setSeverity(FacesMessage.SEVERITY_ERROR);

                    facesMessage.setDetail(ppsResources.getString("errorFromdategreater"));

                    facesMessage.setSummary(ppsResources.getString("errorFromdategreater"));

                    faceContext.addMessage("psInclude:transSearch:SearchForm:selectToDateFormatField", facesMessage);

                    action = "error";

                  }

                  else

                  {

                    action = "success";

                  }

                }

              }

              catch (Exception e) {

                e.printStackTrace();

              }

              return action;

            }

           

          Thanks,

          Siva