Closed thomaspries closed 6 months ago
This is a known limitation. Nested properties aren't supported by <f:validateWholeBean>
. It only supports the bean's own "flat" properties.
Consider using OmniFaces <o:validateBean>
instead. It not only supports nested properties but it will also greatly reduce the <f:validateBean>
and clone()
boilerplate. Detecting nested properties and associating validation errors with them is actually quite complex and a lot of work has been done in crystallizing the <o:validateBean>
on this.
In order to use <o:validateBean>
:
<f:validateBean>
and <f:validateWholeBean>
tags.Cloneable
interface and clone()
method from backing bean.@jakarta.validation.Valid
annotation on private TestData[] data;
property of backing bean.<f:validateWholeBean>
tag was originally located in XHTML, add the <o:validateBean>
with exactly the same attributes:<o:validateBean value="#{testController}" validationGroups="ValidationGroup" />
Note that you can further simplify your <ui:repeat>
on data
as follows as well:
<ui:repeat value="#{testController.data}" var="d">
<h:inputText id="valInput" value="#{d.a}"> <!-- and another one for #{d.b}? -->
<f:validator validatorId="testDataFacesValidator"/>
</h:inputText>
</ui:repeat>
Also note that using EL in ID attribute of <h:inputText>
within <ui:repeat>
has no effect. It has only effect when you use <c:forEach>
instead but that's not necessary. See also https://stackoverflow.com/q/3342984
Thank's for your response (I somehow missed that fact in the documentation), OmniFaces looks promising, I will use that.
... I implemented the steps mentions above and it works perfectly. :-))
Describe the bug
After cloning the bean, all scalar values are copied into the new bean for validation, but modified data in array stay at initial value altough the input values are converted an validated correctly.
To Reproduce
Steps to reproduce the behavior:
to Backingbean and initialise the array with some data (to verify, that conversion and validation of
TestData
works, add scalarTestData x1;
)Validation phase:
Expected behavior
I would like to see altered data in the array to validate them together with the other data.
Desktop