Skip to content

ValidateMultiple: is it correct to invalidate unrendered fields? #783

@NicolaIsotta

Description

@NicolaIsotta

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions