jakartaee / jakartaee/faces

disentangle ViewScope state handling from UIViewRoot.saveState()/restoreState() methods to better control ViewScope state handling

Open
#1,034 9 comments 0 reactions 0 assignees View on GitHub
Component: Components/Renderers Priority: Minor Type: Sub-task
Dominant language
Java
Stars
127
Forks
59
Avg merge
23h
Merged PRs (30d)
7

Description

With #787 a new method restoreViewScopeState was added to UIViewRoot to allow restore ViewScope before buildView is called. But there is no matching saveViewScopeState method.

This issue proposes adding also a method saveViewScopeState() method to UIViewRoot and save the ViewScope state no longer as part of UIViewRoot's state array but rather as an element of the rawState Object[]. Looking at StateManagementStrategyImpl.saveView() - that always returns new Object[]

{ null, stateMap }

; I see element[0] is used to store component structure (full state saving only?). So an additional third element could keep the ViewScope state built from saveViewscopeState() - and restoreState would use thrid rawState element as argument to restoreViewScopeState().

That would allow more flexibility e.g if some impl. or adapter/bridge needs to handle ViewScope state differently. By wrapping UIViewRoot and overriding save-/restoreViewScopeState() methods that would be possible. Currently ViewScope state is bound to UIViewRoot state structure.
#### Affected Versions
[2.2]

Contributor guide

Open the contributing guide

Research direction

Start by reading UIViewRoot's saveState(), restoreState(), and restoreViewScopeState(), then inspect StateManagementStrategyImpl.saveView() and how buildView() orders restoration. The change is complete when ViewScope state has matching save and restore hooks and can be carried separately in the raw state structure, allowing UIViewRoot wrappers to control it independently.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
frontend
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.