MyFaces Core
  1. MyFaces Core
  2. MYFACES-3367

Detect when to wpdate head or body target when content has been updated dynamically

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.10, 2.1.4
    • Component/s: JSR-314
    • Labels:
      None

      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="#

      {testManagedBean.page}

      "/>
      </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.

      1. MYFACES-3367-1.patch
        27 kB
        Leonardo Uribe

        Issue Links

          Activity

          Hide
          Leonardo Uribe added a comment -

          If no objection I'll commit this code soon.

          Show
          Leonardo Uribe added a comment - If no objection I'll commit this code soon.
          Hide
          Luciano Deriu added a comment -

          Hi Leonardo,

          Has this code been checked into a release yet? I've tried the latest build (2.0.12) and it still doesn't work.

          Thanks
          Luciano

          Show
          Luciano Deriu added a comment - Hi Leonardo, Has this code been checked into a release yet? I've tried the latest build (2.0.12) and it still doesn't work. Thanks Luciano
          Hide
          Leonardo Uribe added a comment -

          Hi

          Checking this part, it works on 2.0.11 but stopped working on 2.0.12. I don't know yet the reason, it should work, I'll take a look at it.

          Leonardo

          Show
          Leonardo Uribe added a comment - Hi Checking this part, it works on 2.0.11 but stopped working on 2.0.12. I don't know yet the reason, it should work, I'll take a look at it. Leonardo

            People

            • Assignee:
              Leonardo Uribe
              Reporter:
              Leonardo Uribe
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development