Skip to content

Count Facelets unique ids per row of a c:forEach - #6195

Open
BalusC wants to merge 1 commit into
4.0from
issue_6194
Open

BalusC wants to merge 1 commit into
4.0from
issue_6194

Conversation

@BalusC

@BalusC BalusC commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6194

The build which re-applies the facelet before Render Response matched components by a per-tag counter of applications. A c:if which skipped a row inside a c:forEach therefore made a row find the component of another row, which kept its old row's IndexedValueExpression. The same held for a nested c:forEach whose enclosing row was skipped, and for the context prefix of an include, template, insert, composite component or tag file inside a skipped row.

IterationIds now counts unique ids and context prefixes per row:

  • an outermost iteration keeps byte-identical ids when no row is skipped
  • a nested iteration counts by its own row under a _r<row> path of the enclosing rows
  • a tag applied twice for one row gets a -<n> repeat suffix

Tests:

  • IterationIdsTest and DefaultFaceletContextIterationIdTest pin the counting and the exact id and prefix strings.
  • Issue6194IT covers a flat, a nested and an included c:forEach. All three fail without this fix.

🤖 Assisted by Claude Opus 5.5

A component inside a c:if inside a c:forEach rendered the item of another row after a postback which changed the outcome of the c:if (#6194). The build which re-applies the facelet before Render Response found an existing component by a mark id from a per-tag counter of applications. Once a c:if skipped a row, the n-th application found the component the restoring build had created for the n-th row. A found component keeps its attributes, so it kept the IndexedValueExpression of that row. The same held for a nested c:forEach of which the enclosing row was skipped. It also held for the context prefix of an include, template, insert, composite component or tag file inside a skipped row: its components were recreated and lost their state.

IterationIds now counts these ids and prefixes per row:
- an outermost iteration counts from where the counter stood plus the row, and moves the counter past all its rows when it stops, so ids stay byte-identical when no row is skipped
- a nested iteration counts by its own row under a "_r<row>" path of the enclosing rows
- a tag applied twice for one row gets a "-<n>" repeat suffix

The bug exists since Mojarra 2.0.0. MyFaces does not have it, as its ForEachHandler opens a unique id section per row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BalusC BalusC added this to the 4.0.31 milestone Nov 23, 2026

This branch has not been deployed

No deployments
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