jsr344-experts@javaserverfaces-spec-public.java.net

[jsr344-experts] Re: [220-ViewStateParamNameOnly] PROPOSAL

From: Neil Griffin <neil.griffin_at_portletfaces.org>
Date: Tue, 31 Jan 2012 16:37:00 -0500

Hi Ed,

I believe that my endorsement of Ted's first suggestion still applies.

Agreed, all forms that are under the same ViewRoot will have the same ViewState. But a portal page will contain a ViewRoot for each JSF portlet, and so the value of the "javax.faces.ViewState" hidden field will be different for each ViewRoot.

For example, the following portal page has two JSF portlets on it (Customers and Bookings):
http://www.portletfaces.org/projects/portletfaces-bridge/examples/jsf2-ipc-events

If you view the source of the page, you will see the are two hidden fields with id "javax.faces.ViewState" but each of the hidden fields have a different value.

Using this example, the issue that Alexander was describing was that jsf.js has the potential of doing a partial DOM update on _both_ hidden fields, whereas it should only update _one_ of them. This can happen when the hidden field is the only thing being partially updated via the ajax XML transport. (this is exactly Ted's example below). In such a case, jsf.js needs to operate with "id" of the hidden field (not the id of some surrounding form). If the value of the "id" attribute were namespaced, then Alexander's issue would be solved. It would also solve the problem of uniqueness of each "id" attribute in the rendered HTML document.

But actually there is a larger issue, probably worthy of its own thread, but I'll mention it here. The assumption that jsf.js makes is that there can be only one ViewRoot on a rendered HTML document. During partial updates in which the javax.faces.ViewRoot is being replaced in the DOM (which is basically a full update of the view -- not really partial), jsf.js attempts to replace everything inside the <body></body> elements. In a portlet environment, that would equate to the entire portal page getting replaced, wiping out all the other portlets. Note that I worked around this problem by having a custom ResponseWriter in the portlet bridge that "filters" the response that generates the XML transport. Need to solve this issue in JSF 2.2 for portlet alignment.


Neil

On Jan 31, 2012, at 2:57 PM, Edward Burns wrote:

>>>>>> On Mon, 30 Jan 2012 08:46:08 -0700, Ted Goddard <ted.goddard_at_icesoft.com> said:
>
> TG> If the value can be modified after the page is initially rendered,
> TG> then it should have both a name "javax.faces.ViewState" and an
> TG> ID determined by the naming container hierarchy so that the following
> TG> works correctly:
>
> TG> <update id="javax.faces.ViewState"><![CDATA[-1470762710634119679:-9198324743075498445]]></update>
>
> TG> Or, javax.faces.ViewState should be handled as a special case, with
> TG> all forms from the same view updated together.
>
> Let me clarify. It is certainly the case that all the forms in the page
> will have the same value for the ViewState. Note that in the ajax XML
> transport, we still use "id" and not name. This change only impacts the
> hidden field.
>
> NG> +1 for Ted's first suggestion: Keep the ID attribute, and take it
> NG> one step further by prepending the naming container hierarchy (all
> NG> the way up to PortletNamingContainerUIViewRoot). That would solve
> NG> the XML requirement of all IDs being unique on a page, and guard
> NG> against any portlet problems too.
>
> Neil, does Ted's suggestion, and your endorsement of it, still apply
> even after the clarification I made above?
>
> Ed
>
> --
> | edward.burns_at_oracle.com | office: +1 407 458 0017
> | homepage: | http://ridingthecrest.com/