Validation problems for fields in iterator
[email protected] Thu, 9 Oct 2025 19:44:42 +0000
| Newsgroups | gmane.comp.jakarta.struts.user |
|---|---|
| Message-ID | <trinity-dd7ad56a-7c34-417c-a454-fdcfa33ad3e4-1760039082595@trinity-msg-rest-webde-webde-live-f747bc64b-pjq8s> |
Hi, I am looking for the right syntax to write validations for fields in iterator.
<s:iterator value="mother.child" status="status">
<s:textfield name="mother.child[%{#status.index}].name"/>
<s:textfield name="mother.child[%{#status.index}].pocketmoney" value="%{getFormatted('myDoubleFormat','pocketmoney')}" />
</s:iterator>
(value="%{getFormatted('myDoubleFormat','mother.child[%{#status.index}].pocketmoney')}" caused an OGNL error)
I tried several xml field validators (requiredstring, stringlength, required, double, conversion) starting with:
<field name="mother.child[].name"> or <field name="mother.child.name">
<field name="mother.child[].pocketmoney">
but I get fielderrors for field mother.child[].name (required even all childs have names)
The required validators throw errors, the rest does nothing.
And a conversion error ('x' for pocketmoney) pops up but the field is not populated with the bad value.
(getFormatted worked well in not-iterator-fields, but not here.)
<field-validator type="conversion">
<param name="repopulateField">true</param>
also does not repopulate.
Before I start writing all the validations on myself, I would like to know if there is a better way.
(migrating from Struts1: <field property="pocketmoney" indexedListProperty="child" depends="mask">; can not believe that there is no equivalent in Struts7)
By the way, I am missing @DoubleRangeFieldValidator as @Repeatable (as there is for Integer and Long).
I went into the wrong direction with the double validator, not understanding:
"maxInclusive - the maximum inclusive value in FloatValue format specified by Java language (if none is specified, it will not be checked)."
For German locale , we have to write 9.999,99. No float, just so normal...
And I did not like it that I had to validate decimal places on my own (silent rounding, no error when not matching my format)
Best regards Ute