I'd like to disable/enable SelectManyCheckbox and the SelectOneMenu based on my selection. I have two radio buttons to be selected whether A or B. The SelectManyCheckbox and the SelectOneMenu should be disabled at the first run. When the user selects “A” the SelectManyCheckbox and the SelectOneMenu should be enabled and if the users selects “B”, the SelectManyCheckbox and the SelectOneMenu should be disabled and the items should be empty. I tried to use <f:ajax render="certificates"/>, but it doesn't work properly.

<h:selectOneRadio id="request" layout="pageDirection" value="#{user.hrRequest}" required="true" requiredMessage="Error: Select a Request Type">  
      <f:selectItem itemLabel=" Request A" itemValue="A"/>

             <f:selectItem itemLabel="Request B”  itemValue="B"/>

               <f:ajax render="certificates"/>

</h:selectOneRadio>

<h:selectManyCheckbox value="#{user.hrCertificate2}" id="hrcertificates" disabled="#{user. hrRequest  == ‘B’}"  label="Forward Request to HR" layout="pageDirection" required="true" requiredMessage="Error: Select t least One ">

 <f:selectItems value="#{user.hrCertificate2Value}" />

  </h:selectManyCheckbox>


 <h:selectOneMenu label="c_e_language_hr" disabled="#{user. hrRequest  == 'B'}">

   <f:selectItem itemLabel="Please Select a Language" itemValue="#{user.CertificateLanguage}"/>
    <f:selectItem itemLabel="French" itemValue="fr"/>
    <f:selectItem itemLabel="English" itemValue="en"/>
                </h:selectOneMenu>

So how to do this using ajax

Recommended Answers

All 2 Replies

The code you posted is not JavaScript nor HTML. What is it? Maybe you should ask in the specific forum.

Member Avatar for diafol

I think this is JSF? Should this go to the Java forum?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.