2 Replies Latest reply on Jul 16, 2009 8:18 AM by oneworld95

    Change required attribute of Rich Calendar

    oneworld95

      Hi. I have a selectOneMenu displaying the worker's employment status ("Permanent", "Part-Time", etc.). Elsewhere on the form, I have a Rich Calendar for the End Date, which will be required unless the person chooses "Permanent" in the dropdown box.

      <h:selectOneMenu id="lstEmployeeStatus" value="#{newemployee.employeeStatus}">
       <f:selectItems value="#{newemployee.employeeStatusItems}"/>
      </h:selectOneMenu>
      
      <rich:calendar id="calTentativeEndDate" required="true"
       value="#{newemployee.tentativeEndDate}" requiredMessage="Tentative End Date is required." datePattern="MM-dd-yyyy" />


      How do I change the required property of the Rich Calendar to "false" if the user chooses "Permanent" in the selectOneMenu?



        • 1. Re: Change required attribute of Rich Calendar
          ilya_shaikovsky

          how about to define required with EL?

          • 2. Re: Change required attribute of Rich Calendar
            oneworld95

            Thanks. That's what ended up working. Hope this helps anyone else working on something similar. Here's the working code:

            <h:selectOneMenu id="lstEmployeeStatus" value="#{newemployee.employeeStatus}"
             required="true" requiredMessage="Employee Status is required.">
             <f:selectItems value="#{newemployee.employeeStatusItems}"/>
             <a4j:support event="onchange" reRender="renderPanel" ajaxSingle="true"/>
            </h:selectOneMenu>
            
            <a4j:outputPanel id="renderPanel" ajaxRendered="true">
            <h:outputLabel styleClass="#{newemployee.employeeStatus == 'Permanent' ? '' : 'required'}"
             value="Tentative End Date (for contract or temp employee, intern, or volunteer)"
             for="calTentativeEndDate" />
             <rich:calendar id="calTentativeEndDate" required="#{newemployee.employeeStatus == 'Permanent' ? false : true}"
             value="#{newemployee.tentativeEndDate}" requiredMessage="Tentative End Date is required."
             datePattern="MM-dd-yyyy" />
             <rich:message for="calTentativeEndDate" styleClass="errors" />
            </a4j:outputPanel>