I have two dropdowns in one form. The first contains those options:
String[] decisions = {"acceptée", "rejettée"};
When “rejettée” is selected, I would like to disable the second dropdown.
Here is the relevant code of the two dropdowns:
<p:selectOneMenu required="true" requiredMessage="veuillez choisir une decision" id="dec" value="#{editCommandController.myCom.decision}">
<f:selectItems value="#{editCommandController.decisions}" />
</p:selectOneMenu>
<p:selectOneMenu id="etat" value="#{editCommandController.myCom.etat}">
<f:selectItems value="#{editCommandController.etats}" />
</p:selectOneMenu>
How can I achieve this?
Try this:
To set to some default value on change, try this:
And then in the backing bean add the selectItem if not already present otherwise you can skip it: