I am using jsf 2.1 + primefaces 3.4.1. I've got problems with preventing validation of disabled components.
What I have is approximately this:
<h:form id="form">
<p:dataTable id="parentDataTable" value=#{bean.list} var="parentItem"..>
<p:column>
..
<p:dataTable id="childDataTable" value=#{bean.map[parentItem]}" var="childItem">
<p:column>
<f:facet name="header">
some inputText
</f:facet>
<p:inputText id="inputText"
disabled=#{bean.selectedObjectsMap[childItem]} required="true" requiredMessage="value required" />
<p:message for=":form:parentDataTable:childDataTable:inputText" />
</p:column>
<p:column>
<f:facet name="header">
Select
</f:facet>
<p:selectBooleanCheckbox id="checkBox" value="#{bean.selectedObjectsMap[childItem]}">
<p:ajax update=":form:parentDataTable:childDataTable:inputText" />
</p:selectBooleanCheckbox>
</p:column>
</p:dataTable>
</p:column>
</p:dataTable>
</h:form>
The idea is that by default the inputText component is disabled and the "required value" validation doesn't work when I submit the form. When I click the selectBooleancheckbox component the inputText gets enabled and the "required value" validation works as well when I submit the form. However, when I disable the inputText back the validation continues to work and the "value required" message appears and I cannot submit the form. It seems that the JSF UI component tree on the server side doesn't properly get updated when I click on the checkbox, although visually I can see that the inputText component gets disabled every time I click on the checkbox.
Any ideas how I can resolve this?
If your validation isnt more complex than shown in this sample code, you code turn it on and off using
<p:inputText id="inputText" disabled="#{bean.selectedObjectsMap[childItem]}" required="#{!bean.selectedObjectsMap[childItem]}" requiredMessage="value required" />
Meaning you toggle required attribute with same bean value as used for disabled attribute, just add a !