|<< Back to previous view|
[JAVASERVERFACES_SPEC_PUBLIC-1093] The id attribute of javax.faces.ViewState is not unique Created: 01/May/12 Updated: 08/Nov/13
|Affects Version/s:||2.2 Sprint 12|
|Remaining Estimate:||Not Specified|
|Time Spent:||Not Specified|
|Original Estimate:||Not Specified|
|Participants:||dmsinotte, Ed Burns and tedgoddard|
As per the work done for this spec change, http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-220, the id of each hidden ViewState element is supposed to be unique on the page. This should hold true for multiple forms in a single view as well as multiple views on the page (e.g. portlets). The documentation in ResponseStateManager indicates that this should be done by setting the id to be:
I have attached a test case which has two forms on it. The resulting ViewState elements both have identical ids:
ViewState for form1: j_id1:javax.faces.ViewState:0
The counter is not incremented and the id of the form (which should be the naming container in this case) is not used.
Also, I noticed that the method for getting the ViewState id is com.sun.faces.util.Util.getViewStateId(FacesContext fc). For those of us working on extending the framework who might need access to the information in their own renderers, will there be a way to get at the information in a more public way?
|Comment by tedgoddard [ 03/May/12 04:25 PM ]|
(First of all, javax.faces.ViewState should not be modified for Ajax updates using server-side state-saving, but this simple approach does not appear to be the current direction.)
We are a bit unclear on how the current implementation is intended to work, but expect that something like the following is necessary:
When the request is submitted, call getElementsByName('javax.faces.ViewState') and store the list of IDs for all with equal value to that of the javax.faces.ViewState in the submitting form. In the case of future JSP inclusion or current Portlets, there will be javax.faces.ViewState fields not associated with the current view. They will have different values and are not included in the list.
When the partial response is generated, it may contain rendered hidden inputs with name javax.faces.ViewState and unique IDs, but also contains the special case <update id="javax.faces.ViewState"><![CDATA[...]]></update>. The previously stored list of IDs are now all updated to use the new value. Any javax.faces.ViewState hidden fields that have been modified by the page update itself (potentially now having different IDs) have the correct value anyway because they were just updated.
|Comment by Ed Burns [ 03/May/12 06:35 PM ]|
TG> (First of all, javax.faces.ViewState should not be modified for Ajax
Can you please elaborate more on what you mean by this? The issue
TG> We are a bit unclear on how the current implementation is intended
TG> When the request is submitted, call
TG> When the partial response is generated, it may contain rendered
These two comments are better suited to JAVASERVERFACES_SPEC_PUBLIC-790,