Skip to content

WW-3624 feat(tags): allow regex matching of field names on fielderror tag - #2036

Merged
lukaszlenart merged 1 commit into
mainfrom
WW-3624-fielderror-regex
Oct 16, 2026
Merged

lukaszlenart merged 1 commit into
mainfrom
WW-3624-fielderror-regex

Conversation

@lukaszlenart

Copy link
Copy Markdown
Member

Fixes WW-3624

Summary

Adds a regex attribute (default false) to <s:fielderror>. When enabled, fieldName and nested <s:param> values are regular expressions matched against the whole field error name, e.g. all errors of one iterated row:

<s:fielderror regex="true">
    <s:param>ledger\.records\[<s:property value="#row.index"/>\]\..*</s:param>
</s:fielderror>
  • simple and html5 fielderror.ftl: in regex mode the template first collects the matching error keys, then renders them through the existing loop. The exact-match path is unchanged.
  • javatemplates FieldErrorHandler: same matching via Pattern.matcher(...).matches().
  • A field error matched by several patterns is rendered once; errors keep the order in which validation recorded them.
  • regex is reset in clearTagStateForTagPoolingServers.

This follows the design of the patch attached to the ticket, ported to the current templates (it only covered simple). Prefix matching without escaping is tracked separately in WW-5784.

Notes

  • Pre-existing difference, left as is: when no listed name matches, FieldErrorHandler writes an empty <ul class="errorMessage"></ul> while the FreeMarker themes write nothing. Regex mode follows each renderer's existing behaviour.
  • The fielderror tag page in struts-site needs the new attribute.

Test plan

  • New FieldErrorTagTest cases for simple and html5 (row match, no match, whole-name match, no duplicates, literal match without regex, tag-pooling reset); the matching cases failed before the template change
  • New FieldErrorTest cases in javatemplates
  • core: 3490 tests, 0 failures; javatemplates: 83 tests, 0 failures

🤖 Generated with Claude Code

… tag

Adds a regex attribute (default false) to s:fielderror. When enabled,
fieldName and nested param values are regular expressions matched
against the whole field error name, e.g. to show all errors of one
iterated row. Each field error is rendered once even when several
patterns match it. Implemented in the simple and html5 themes and
the javatemplates FieldErrorHandler.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

@lukaszlenart
lukaszlenart marked this pull request as ready for review October 16, 2026 11:14
@lukaszlenart
lukaszlenart merged commit 2f7e086 into main Oct 16, 2026
8 checks passed
@lukaszlenart
lukaszlenart deleted the WW-3624-fielderror-regex branch October 16, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant