Uploaded image for project: 'PUBLIC - Liferay Faces'
  1. PUBLIC - Liferay Faces
  2. FACES-2974

Some children of jsf <head> components are not written to the response

    Details

      Description

      This bug causes all children of h:head to not be rendered except outputStylesheet and outputScript components (ex: <script>, <style>, link, meta etc. fail to render).

      Steps to reproduce:

      1. Add the following code to the <h:head> tag of the jsf-applicant-portlet's portletViewMode.xhtml:
         <script type="text/javascript" src="https://rawgit.com/stiemannkj1/d3fdd05557c0df32bf1c1e7e45f51c9c/raw/9b2bd1df7d74b4c08efe63b0a42684fba0c009f9/test-js.js"></script>
        
      2. Deploy the portlet and navigate to it.

      If the bug still exists, the portlet will render, no alert with appear, and the <script> markup will not appear in the browser.

      If the bug is fixed, the <script> markup will appear in the browser, and an alert will appear with the following text:

      test-js.js loaded

      Workaround

      To workaround this issue, you can create a composite component with a name attribute. The name must end in either "css" or "js" and should probably be unique per view to ensure that it is always loaded. For example to render scripts like the one mentioned above in the head section, create the following resources/workaround/headElements.xhtml file:

      <?xml version="1.0" encoding="UTF-8"?>
      <ui:component xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
          xmlns:cc="http://xmlns.jcp.org/jsf/composite" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.w3.org/1999/xhtml http://www.w3.org/2002/08/xhtml/xhtml1-transitional.xsd">
      
          <!-- Workaround for https://issues.liferay.com/browse/FACES-2974 -->
          <cc:interface>
              <cc:attribute name="name" required="true" />
          </cc:interface>
      
          <cc:implementation>
              <cc:insertChildren />
          </cc:implementation>
      
      </ui:component>
      

      To use this component with the script mentioned above:

      <workaround:headElements name="#{view.viewId}.js">
          <script type="text/javascript"
          src="https://rawgit.com/stiemannkj1/d3fdd05557c0df32bf1c1e7e45f51c9c/raw/9b2bd1df7d74b4c08efe63b0a42684fba0c009f9/test-js.js"></script>
      </workaround:headElements>
      

        Attachments

          Activity

            People

            • Assignee:
              kyle.stiemann Kyle Stiemann
              Reporter:
              kyle.stiemann Kyle Stiemann
              Participants of an Issue:
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Subcomponents