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

HTTP 404 error returned for URLs that contain an EL expression using the resource keyword

    Details

      Description

      This bug was discovered while testing the FacesBridge TCK TestPage219 (resourcesRenderedInHeadTest) on both Apache Pluto 3.0 and Liferay Portal 7.1.0-SNAPSHOT.

      The test includes a Facelet view named resourcesRenderedInHeadTest.xhtml that contains an EL expression with the resource keyword:

      resourcesRenderedInHeadTest.xhtml
      <script id="resource1_js" type="text/javascript" src="#{resource['test:resource1.js']}"></script>
      

      On Apache Pluto, the URL for the src attribute is rendered as:

      <script id="resource1_js" type="text/javascript" src="/com.liferay.faces.test.bridge.tck.main.portlet/javax.faces.resource/
      resource1.js?ln=test"></script>
      

      On Liferay Portal, the URL for the src attribute is:

      <script id="resource1_js" type="text/javascript" src="/o/com.liferay.faces.test.bridge.tck.main.portlet/javax.faces.resource/resource1.js?ln=test"></script>
      

      These URLs are not absolute ResourceURLs. Instead, they are relative URLs that are suited for a webapp environment. Because of this they generate a 404 error.

      The solution to this problem is to use the following syntax:

      resourcesRenderedInHeadTest.xhtml
      <script id="resource1_js" type="text/javascript" src="#{facesContext.externalContext.encodeResourceURL(resource['test:resource1.js'])}"></script>
      

      Note: While debugging, it became apparent that null values were being added to the componentResourceStack. This may or may not be related to the problem.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                neil.griffin Neil Griffin
                Reporter:
                neil.griffin Neil Griffin
                Participants of an Issue:
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Packages

                  Version Package
                  bridge-impl-5.0.0