1 Reply Latest reply on Jun 18, 2013 8:15 AM by jhuska

    How to disable richfaces:calendar?

    jayas

      Is it possible to disable rich:calendar component in Richfaces 4.3.1? I have rich:calendar and a rich:inputText. The requirement is user can select either of these components. For eg..if user enters data in inputtext, the calendar component should get disabled. I tried with "disabled" attribute. But it doesn't work.

       

      The calendar component that we are using should allow manual input as well as popup. The requirement is to disable the calendar component when user selects the radio button corresponding to inputtext.

       

      XHTML Page:

      <h:selectOneRadio name="searchCriteria" layout="pageDirection" id="searchCriteria" value="#{searchBean.searchvalue}">

          <f:selectItem itemLabel="Joining Date:" name="joinDate"  itemValue="joinDate" />

          <f:selectItem itemLabel="Student #:" name="studentNbr"  itemValue="studentNbr" />

          <a4j:ajax immediate="true"   render="fromTime,toTime,studentNumber,studentName" event="click"></a4j:ajax>

      </h:selectOneRadio>

      <rich:calendar name="fromTime" id="fromTime" datePattern="MM/dd/yyyy"  enableManualInput="true" value="#{searchBean.fromTime}"  disabled="#{searchBean.checkType('studentNbr')}"

      converterMessage="Could not be understood as Date">

          <rich:placeholder value="From" />

      </rich:calendar>

      <rich:calendar name="toTime" id="toTime" datePattern="MM/dd/yyyy"  enableManualInput="true" value="#{searchBean.toTime}"  disabled="#{searchBean.checkType('studentNbr')}"> 

          <rich:placeholder value="To" />

      </rich:calendar>

      <h:inputText value="#{searchBean.studentNumber}" name="studentNumber"  id="studentNumber" disabled="#{searchBean.checkType('joinDate')}"></h:inputText>

      <h:inputText value="#{searchBean.studentName}" name="studentName"  id="studentName" disabled="#{searchBean.checkType('joinDate')}">

          <rich:placeholder value="Name" />

      </h:inputText>

       

      SearchBean.java

      public Boolean checkType(String searchvalue) {
          Boolean tmp = this.searchvalue.equalsIgnoreCase(searchvalue);
          return tmp;
      }

       

      My questions are:

      1. Is it possible to disable calendar component based on radio button selection? Or do we need to write any custom component?

      2. The requirement is just to the calendar component. But when I select radio button corresponding to the inputtext, the calendar component disappears. If I refresh the page, the calendar component appears correctly in disabled state.

       

      Any suggestion is much appreciated!!!

       

      Thanks.