Description
Related to topic sent on jsr344-experts list:
[jsr344-experts] Facelet page with dynamic content and update ajax content does not work as user expects
Now take a look at this example:
include.xhtml
<h:commandLink ...>
<f:ajax render="content"/>
</h:commandLink>
...
<f:subview id="content">
<ui:include src="#
"/>
</f:subview>
page1.xhtml
<ui:composition
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:outputText id="component1" value="Page 1"/>
<!-- ... more components ... -->
</ui:composition>
page2.xhtml
<ui:composition
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:outputStylesheet ... />
<h:outputText id="component2" value="Page 2"/>
<!-- ... more components ... -->
</ui:composition>
Here the problem is if the dynamic content changes and add a resource under
"head" target (h:outputStylesheet does that), shouldn't be added a section
on the ajax payload to update the <head> section? In theory yes, because
this breaks encapsulation principle. If the user says render all inside
content if the <head> section changes it is responsability of the framework
(in this case PartialViewContext) to detect that an send the correct
payload, right?. Here we have two options:
a. Keep track of the resources rendered and save that on the state, then use
that information to check if the head should be rendered.
b. Use PostAddToViewEvent to check when a change on the component tree has
triggered a change on the head.
Option b. save some bytes on the state but it could cause render <head>
section more than necessary (for example a dynamic change but the head
has already rendered the resource, so it is not necessary). Option a.
impose that you need a way to check if the <head> was changed, and
require changes on the spec.
I'll solve this problem adding a web config param:
org.apache.myfaces.STRICT_JSF_2_REFRESH_TARGET_AJAX
on MyFaces and doing some
changes on the algorithm, adding a flag to indicate if a view is being built
by first time.
Attachments
Attachments
Issue Links
- is cloned by
-
MYFACES-3462 REGRESSION - Detect when to wpdate head or body target when content has been updated dynamically
- Closed
- is duplicated by
-
MYFACES-3106 Resources not loaded when using a dynamic ui:inlclude and rendered via ajax
- Closed