Skip to content

Evaluate c:forEach items less often when replaying decisions - #6149

Merged
BalusC merged 2 commits into
4.0from
issue_6148
Nov 9, 2026
Merged

BalusC merged 2 commits into
4.0from
issue_6148

Conversation

@BalusC

@BalusC BalusC commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Closes #6148

With com.sun.faces.restoreBuildTimeDecisions, the items of a <c:forEach> are now resolved less often on a postback:

Phase Before After
Restore View 2 1
Before rendering 3 2

The restoring build reuses the value it already resolved, and the two decisions of one iteration share one evaluation. The value is only reused while restoring a view, because a action or preRenderView listener can replace the items before rendering.

The issue also proposed evaluating rendered once per encodeAll. That is not possible before Faces 5.0, where encodeAll() evaluates it with the component pushed (jakartaee/faces#1002): here encodeAll() evaluates it before pushComponentToEL and encodeBegin() after it, so #{component} differs between them. A page where the expression is true for the parent and false for the component rendered differently with the cache. This PR documents that in encodeBegin() and pins it with a test.

Tests: added UIComponentBaseEncodeAllTest and IterationBaseCacheTest. The impl unit tests pass. The getter counts above were measured on a running application. No integration test covers them yet.

🤖 Generated with Claude Opus 5.5

BalusC and others added 2 commits November 8, 2026 17:09
encodeAll() evaluates rendered before pushComponentToEL and encodeBegin()
evaluates it after, so #{component} is the parent in the first and the
component itself in the second. Reusing the first result changes what is
rendered. Document this in encodeBegin() and pin it with a test.

Also correct the javadoc of cachedIsRendered, which claimed that an
aborted encode cannot leave a stale value.

Refs #6148

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With restoreBuildTimeDecisions, the build which restores the view
resolved the items a second time to check each row, and the two
decisions of one iteration each evaluated them before rendering.
Reuse the value in the restoring build, and combine both decisions.

Refs #6148

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BalusC BalusC added this to the 4.0.30 milestone Nov 8, 2026
@BalusC
BalusC merged commit b5cd634 into 4.0 Nov 9, 2026
2 checks passed
@BalusC
BalusC deleted the issue_6148 branch November 9, 2026 12:05
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