jakartaee / jakartaee/faces

UIViewParameter state saving algorithm

Open
#795 12 comments 0 reactions 0 assignees View on GitHub
Component: Components/Renderers Priority: Major Type: Bug
Dominant language
Java
Stars
127
Forks
59
Avg merge
23h
Merged PRs (30d)
7

Description

From the mail "State saving of UIViewParameter" on jsr-314-open:

UIViewParameter uses the submittedValue to store its value in the state for the
next postback, because obviously the view parameter won't be in the request
parameter map of the next request (which is the postback). But because its
submittedValue is null after the conversions and validations, it has to be set
again before the state is generated. To accomplish that, the spec currently
states to override encodeAll() and make the call to setSubmittedValue() there.
In addition, encodeAll() has to be called in UIViewRoot.encodeEnd() for every
UIViewParameter in the view. This works perfectly for normal requests, but when
you are using an AJAX request the state is generated before
UIViewRoot.encodeEnd() is called an thus the submittedValue for every
UIViewParameter is null in the state. This means that the value of every
UIViewParameter will be null in the following request.

Now the easiest solution to this problem, which I also already committed to
MyFaces trunk (again see [1] for details), is to do mostly the same as in
UIViewRoot.encodeEnd() just also in PartialViewContext.
processPartial() when the PhaseId is RENDER_RESPONSE before the state is
generated to make it work for AJAX-requests.

However I don't really like this solution, because we have to think of handling
UIViewParameters in a special way every time we change something on any render
mechanism. Why don't we just override saveState() on UIViewParameter and set the
submittedValue there before the state is saved. This will have the same result,
but without the code in UIViewRoot, PartialViewContext and
UIViewParameter.encodeAll() and without future headaches. I also already
uploaded a patch for this to the MyFaces issue at [1].

Answer to this from Martin Marinschek: "This is just a so much better solution
![](https://java.net/jira/images/icons/emoticons/wink.gif). We should spec this one."

[1] [https://issues.apache.org/jira/browse/MYFACES-2645](https://issues.apache.org/jira/browse/MYFACES-2645)
#### Environment
Operating System: All
Platform: All
#### Affected Versions
[2.0]

Contributor guide

Open the contributing guide

Research direction

Start by reading the UIViewParameter state-saving behavior and the related UIViewRoot and PartialViewContext render paths described in the issue, then review the linked MYFACES-2645 patch. Done means the submitted value is preserved for the next AJAX postback without requiring separate handling in each render mechanism.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
web-dev
Issue type
Bug
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.