Your solution is the right approach, but the issue is that ADF can not change the checkbox value as long as the required
constraint of the choice box is not fulfilled. So you will always get the "A selection is required" message and the new value of the check box will not be updated on the server as long as there is nothing selected in the choice box.
To solve this, you need to set the immediate
property on the checkbox to true
to skip validation, and add a valueChangeListener
to handle the changes of the checkbox and manually call the render response phase:
<af:selectBooleanCheckbox id="sbc1" label="Skip Choice"
value="#{sessionBean.skipInput}"
autoSubmit="true"
immediate="true"
valueChangeListener="#{sessionBean.toggleSkipInput}"/>
public class SessionBean {
...
public void toggleSkipInput(ValueChangeEvent vce) {
setSkipInput(Boolean.TRUE.equals(vce.getNewValue()));
FacesContext.getCurrentInstance().renderResponse();
}
}
For more information, see