Consider this example:
<h:inputText id="text1"/>
<h:inputText id="text2"/>
<h:inputText id="text3" rendered="#{myBean.shouldRender}"/>
<o:validateMultiple id="multipleValidator" validator="#{myBean.validator}" components="text1 text2 text3"/>
where #{myBean.shouldRender} evaluates to false.
Suppose the form is submitted and #{myBean.validator} returns false. All referenced components will be invalidated, including text3, even if it's not rendered. Then, when the form is submitted and components are collected here:
|
for (String clientId : components.split("\\s+")) { |
|
for (UIInput input : findInputComponents(namingContainerParent, clientId, PropertyKeys.components)) { |
|
if (!input.isValid()) { |
|
return Collections.emptyList(); |
|
} |
|
|
|
inputs.add(input); |
|
} |
|
} |
text3 will be invalid because its status is not resetted, so
#{myBean.validator} won't be called anymore:
|
List<UIInput> inputs = collectComponents(); |
|
|
|
if (inputs.isEmpty()) { |
|
return; |
|
} |
I think there are two possible solutions:
- do not collect components if they are not rendered
- do not invalidate components if they are not rendered
I can prepare a PR if needed. WDYT?
Consider this example:
where
#{myBean.shouldRender}evaluates tofalse.Suppose the form is submitted and
#{myBean.validator}returnsfalse. All referenced components will be invalidated, includingtext3, even if it's not rendered. Then, when the form is submitted and components are collected here:omnifaces/src/main/java/org/omnifaces/component/validator/ValidateMultipleFields.java
Lines 255 to 263 in dbe8012
text3will be invalid because its status is not resetted, so#{myBean.validator}won't be called anymore:omnifaces/src/main/java/org/omnifaces/component/validator/ValidateMultipleFields.java
Lines 213 to 217 in dbe8012
I think there are two possible solutions:
I can prepare a PR if needed. WDYT?