0 Replies Latest reply on Nov 21, 2012 5:40 AM by rob_

    [Beginner Question] How to put data from <rich:calendar /> into submitted request

    rob_ Newbie

      Hi,

       

      I'm currently bound to a JSF1-based project, using rich-faces-3.x. Unluckily I was unable to get the data from added <rich:calendar/> in my backing bean.

      My idea adding the following calendars in the xhtml-template:

       

      <a4j:outputPanel id="dateF" layout="block" >

        <rich:calendar value="#{MyBean.currentNws.validFrom}"

            id="calDateF"

            locale="de/DE"

            popup="true"

            datePattern="dd.M.yy"

            showApplyButton="true" cellWidth="24px" cellHeight="22px" style="width:200px">

        </rich:calendar>

      </a4j:outputPanel>

      <a4j:outputPanel id="dateT" layout="block">

        <rich:calendar value="#{MyBean.currentNws.validUntil}"

            id="calDateT"

            locale="de/DE"

            popup="true"

            datePattern="dd.M.yy"

             showApplyButton="true" cellWidth="24px" cellHeight="22px" style="width:200px">

        </rich:calendar>

      </a4j:outputPanel>

      <!-- ... -->

      <h:commandLink styleClass="button" action="#{MyBean.save}" value="Save" rendered="true"/>

       

      The corresponding backing bean looks like this:

       

      final String requestDateFrom = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("dateF");

      final String requestDateTo = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("dateT");

      final SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yy"); // format used in frontend

      try {

          // parse "from" date

          if (!ValidityHelper.isEmpty(requestDateFrom)) {

              nws.setValidFrom(dateFormat.parse(requestDateFrom));

          }

          // parse "to"/"until" date

          if (!ValidityHelper.isEmpty(requestDateFrom)) {

          nws.setValidUntil(dateFormat.parse(requestDateUntil));

              // add start date for this case

              if (ValidityHelper.isEmpty(requestDateFrom)) {

                  nws.setValidFrom(new Date());

              }

          }

      } catch (ParseException exception) {

         // ...

      }

       

      Unluckily "dateF" and "dateT" seem to be empty...

       

      Any help is greatly appreciated.

       

      Regs,

      Rob