I have a check-box that disables some form.
<h:selectBooleanCheckbox id="ldapAuthEnabled" value="#{enabled}" label="check it">
When I check it - it lead to disable all field in my form, so that:
<h:inputText mandatory="true" value="#{someVar}"
disabled="#{!enabled}" required="#{enabled}" />
The problem comes up when
- I try to safe my form when fields are not disabled - it shows me validation messages!
- Then I click on the check-box, it makes all fields disabled, BUT - it still show me validation messages! So, It even can not go to my controller.safe() method because of this.
The question is: how to make it work as expected? - when fields are disabled, no need to keep validation messages and think that form is not valid.
-- EDIT:
As suggested in the answer (from BalusC), I changed "value" to "binding", so now I have code like this:
<h:panelGroup id="my-panel">
<h:selectBooleanCheckbox id="myEdit" binding="#{checkbox}" label="enable it!">
<f:ajax event="click" render="my-panel"/>
</h:selectBooleanCheckbox>
<h:inputText id="name" value="#{bean.name}" disabled="#{not checkbox.value}" required="true" />
<h:outputText value="sometext"/>
</h:panelGroup>
Where "<h:panelGroup id="my-panel">"
is part of the "form".
But have the same result - validation error that prevent me to do save().
I use "SessionScope" for my bean now.