javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-2348

Implement javax.faces.WebAppResourcesDirectory context param

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.2.0-m05
    • Component/s: resources
    • Labels:
      None

      Issue Links

        Activity

        Hide
        Ed Burns added a comment -

        This commit, from <http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-548>, goes a long way toward implementing this. But please check it and add tests.

        Sending build.xml
        Sending jsf-api/src/main/java/javax/faces/application/Resource.java
        Sending jsf-api/src/main/java/javax/faces/application/ResourceHandler.java
        Sending jsf-ri/src/main/java/com/sun/faces/application/resource/ClasspathResourceHelper.java
        Sending jsf-ri/src/main/java/com/sun/faces/application/resource/ClientResourceInfo.java
        Sending jsf-ri/src/main/java/com/sun/faces/application/resource/FaceletResourceHelper.java
        Sending jsf-ri/src/main/java/com/sun/faces/application/resource/LibraryInfo.java
        Sending jsf-ri/src/main/java/com/sun/faces/application/resource/ResourceHelper.java
        Sending jsf-ri/src/main/java/com/sun/faces/application/resource/ResourceInfo.java
        Sending jsf-ri/src/main/java/com/sun/faces/application/resource/WebappResourceHelper.java
        Sending jsf-ri/src/main/java/com/sun/faces/config/WebConfiguration.java
        Sending jsf-ri/systest-per-webapp/resource-locale-prefix/src/java/com/sun/faces/systest/ResourceLocalePrefixTestCase.java
        Adding (bin) jsf-ri/systest-per-webapp/resource-locale-prefix/web/resources/duke-non-localized-non-lib.gif
        Adding jsf-ri/systest-per-webapp/resource-locale-prefix/web/resources/lib
        Adding (bin) jsf-ri/systest-per-webapp/resource-locale-prefix/web/resources/lib/duke-non-localized.gif
        Sending jsf-ri/systest-per-webapp/resource-locale-prefix/web/test.jsp
        Transmitting file data ...............
        Committed revision 9778.

        http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-548 http://java.net/jira/browse/JAVASERVERFACES-2348

        The central feature of this changebundle enables an additional check
        when rendering a resource, and serving up the bytes of the resource.
        The additional check is to look for a non-localized version of the
        resource in the case when the user has provided a localePrefix, but
        there is no localized version of the resource. This solves the case
        that Cay Horstmann is talking about in the bug report.

        Consider this situation, which is not uncommon.

        I need a JavaScript library for all locales

        I need images that vary by locale
        Resource handling, as described in section 2.6, makes it impossible to vary the
        images by locale without also unnecessary duplicating the JavaScript.

        This feature is referred to as "additional check" for discussion in
        this changebundle.

        SECTION: Modified Files
        ----------------------------
        M requestProcessingLifecycle.fm

        Fix 2.6.1.4 so that it correctly handles the additional check.

        M jsf-api/src/main/java/javax/faces/application/ResourceHandler.java

        for all variants of createResource() that reference section
        JSF.2.6.1.4, mention that there are new requirements in that section
        that fix the problem described in JAVASERVERFACES_SPEC_PUBLIC-548.

        libraryExists(), new requirements. "If there is a localePrefix for
        this application, as defined in LOCALE_PREFIX, first look for the
        library with the prefix. If no such library is found, look for the
        library without the prefix. This allows developers to avoid
        duplication of files. For example, consider the case where the
        developer wants to have a resource library containing a localized
        image resource and a non-localized script resource. By checking both
        locations for the existence of the library, along with other spec
        changes in section 2.6.1.4, this scenario is enabled."

        M jsf-api/src/main/java/javax/faces/application/Resource.java

        changes to getRequestPath().

        JSF 2.0 should have specified the "loc" query parameter, but it did
        not. Fix that.

        M jsf-ri/src/main/java/com/sun/faces/config/WebConfiguration.java

        Implement javax.faces.WebAppResourcesDirectory, but need to add tests.

        M jsf-ri/src/main/java/com/sun/faces/application/resource/ClientResourceInfo.java

        Add copy ctor, and copy method. These are necessary to support the
        additional check.

        Move equals() and hashcode() up to superclass.

        M jsf-ri/src/main/java/com/sun/faces/application/resource/ResourceInfo.java

        Move ivars to top of class definition.

        Add copy ctor, and copy method. These are necessary to support the
        additional check.

        Take on equals and hashCode().

        M jsf-ri/src/main/java/com/sun/faces/application/resource/FaceletResourceHelper.jav

        implement equals() and hashCode()

        M jsf-ri/src/main/java/com/sun/faces/application/resource/LibraryInfo.java

        Add copy ctor, to support the additional check.

        add getPath(String localePrefix) to support the additional check.

        M jsf-ri/src/main/java/com/sun/faces/application/resource/WebappResourceHelper.java

        implement WebAppResourcesDirectory configurability.

        Add equals() and hashCode().

        use getPath(localePrefix)

        M jsf-ri/src/main/java/com/sun/faces/application/resource/ResourceHelper.java

        In method getInputStream() move the heart of the method into a new
        method, getInputStreamFromClientInfo(). Call this method first, it
        will cause the resource to be looked for given the localePrefix, if
        one exists for this app. If it is not found, use the new copy methods
        on ClientResourceInfo to create a resourceInfo with its localePrefix
        artifically removed. Pass this to getInputStreamFromClientInfo(). If
        the resource is found, use the copy() method to modify the resource
        and effectively remove its localePrefix. Otherwise, return null.

        Because this method is called from both WebappResourceHelper and
        ClasspathResourceHelper, both cases are covered.

        M jsf-ri/src/main/java/com/sun/faces/application/resource/ClasspathResourceHelper.java

        add equals() and hashCode().

        M jsf-ri/systest-per-webapp/resource-locale-prefix/src/java/com/sun/faces/systest/ResourceLocalePrefixTestCase.java
        M jsf-ri/systest-per-webapp/resource-locale-prefix/web/test.jsp
        A jsf-ri/systest-per-webapp/resource-locale-prefix/web/resources/duke-non-localized-non-lib.gif
        A jsf-ri/systest-per-webapp/resource-locale-prefix/web/resources/lib
        A jsf-ri/systest-per-webapp/resource-locale-prefix/web/resources/lib/duke-non-localized.gif

        New test content.

        Show
        Ed Burns added a comment - This commit, from < http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-548 >, goes a long way toward implementing this. But please check it and add tests. Sending build.xml Sending jsf-api/src/main/java/javax/faces/application/Resource.java Sending jsf-api/src/main/java/javax/faces/application/ResourceHandler.java Sending jsf-ri/src/main/java/com/sun/faces/application/resource/ClasspathResourceHelper.java Sending jsf-ri/src/main/java/com/sun/faces/application/resource/ClientResourceInfo.java Sending jsf-ri/src/main/java/com/sun/faces/application/resource/FaceletResourceHelper.java Sending jsf-ri/src/main/java/com/sun/faces/application/resource/LibraryInfo.java Sending jsf-ri/src/main/java/com/sun/faces/application/resource/ResourceHelper.java Sending jsf-ri/src/main/java/com/sun/faces/application/resource/ResourceInfo.java Sending jsf-ri/src/main/java/com/sun/faces/application/resource/WebappResourceHelper.java Sending jsf-ri/src/main/java/com/sun/faces/config/WebConfiguration.java Sending jsf-ri/systest-per-webapp/resource-locale-prefix/src/java/com/sun/faces/systest/ResourceLocalePrefixTestCase.java Adding (bin) jsf-ri/systest-per-webapp/resource-locale-prefix/web/resources/duke-non-localized-non-lib.gif Adding jsf-ri/systest-per-webapp/resource-locale-prefix/web/resources/lib Adding (bin) jsf-ri/systest-per-webapp/resource-locale-prefix/web/resources/lib/duke-non-localized.gif Sending jsf-ri/systest-per-webapp/resource-locale-prefix/web/test.jsp Transmitting file data ............... Committed revision 9778. http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-548 http://java.net/jira/browse/JAVASERVERFACES-2348 The central feature of this changebundle enables an additional check when rendering a resource, and serving up the bytes of the resource. The additional check is to look for a non-localized version of the resource in the case when the user has provided a localePrefix, but there is no localized version of the resource. This solves the case that Cay Horstmann is talking about in the bug report. Consider this situation, which is not uncommon. I need a JavaScript library for all locales I need images that vary by locale Resource handling, as described in section 2.6, makes it impossible to vary the images by locale without also unnecessary duplicating the JavaScript. This feature is referred to as "additional check" for discussion in this changebundle. SECTION: Modified Files ---------------------------- M requestProcessingLifecycle.fm Fix 2.6.1.4 so that it correctly handles the additional check. M jsf-api/src/main/java/javax/faces/application/ResourceHandler.java for all variants of createResource() that reference section JSF.2.6.1.4, mention that there are new requirements in that section that fix the problem described in JAVASERVERFACES_SPEC_PUBLIC-548 . libraryExists(), new requirements. "If there is a localePrefix for this application, as defined in LOCALE_PREFIX, first look for the library with the prefix. If no such library is found, look for the library without the prefix. This allows developers to avoid duplication of files. For example, consider the case where the developer wants to have a resource library containing a localized image resource and a non-localized script resource. By checking both locations for the existence of the library, along with other spec changes in section 2.6.1.4, this scenario is enabled." M jsf-api/src/main/java/javax/faces/application/Resource.java changes to getRequestPath(). JSF 2.0 should have specified the "loc" query parameter, but it did not. Fix that. M jsf-ri/src/main/java/com/sun/faces/config/WebConfiguration.java Implement javax.faces.WebAppResourcesDirectory, but need to add tests. M jsf-ri/src/main/java/com/sun/faces/application/resource/ClientResourceInfo.java Add copy ctor, and copy method. These are necessary to support the additional check. Move equals() and hashcode() up to superclass. M jsf-ri/src/main/java/com/sun/faces/application/resource/ResourceInfo.java Move ivars to top of class definition. Add copy ctor, and copy method. These are necessary to support the additional check. Take on equals and hashCode(). M jsf-ri/src/main/java/com/sun/faces/application/resource/FaceletResourceHelper.jav implement equals() and hashCode() M jsf-ri/src/main/java/com/sun/faces/application/resource/LibraryInfo.java Add copy ctor, to support the additional check. add getPath(String localePrefix) to support the additional check. M jsf-ri/src/main/java/com/sun/faces/application/resource/WebappResourceHelper.java implement WebAppResourcesDirectory configurability. Add equals() and hashCode(). use getPath(localePrefix) M jsf-ri/src/main/java/com/sun/faces/application/resource/ResourceHelper.java In method getInputStream() move the heart of the method into a new method, getInputStreamFromClientInfo(). Call this method first, it will cause the resource to be looked for given the localePrefix, if one exists for this app. If it is not found, use the new copy methods on ClientResourceInfo to create a resourceInfo with its localePrefix artifically removed. Pass this to getInputStreamFromClientInfo(). If the resource is found, use the copy() method to modify the resource and effectively remove its localePrefix. Otherwise, return null. Because this method is called from both WebappResourceHelper and ClasspathResourceHelper, both cases are covered. M jsf-ri/src/main/java/com/sun/faces/application/resource/ClasspathResourceHelper.java add equals() and hashCode(). M jsf-ri/systest-per-webapp/resource-locale-prefix/src/java/com/sun/faces/systest/ResourceLocalePrefixTestCase.java M jsf-ri/systest-per-webapp/resource-locale-prefix/web/test.jsp A jsf-ri/systest-per-webapp/resource-locale-prefix/web/resources/duke-non-localized-non-lib.gif A jsf-ri/systest-per-webapp/resource-locale-prefix/web/resources/lib A jsf-ri/systest-per-webapp/resource-locale-prefix/web/resources/lib/duke-non-localized.gif New test content.
        Hide
        Ed Burns added a comment -

        I'm just looking for someone to closely inspect the implementation I made, and add some automated test coverage for it. I'm not very confident in the initial implementation.

        Show
        Ed Burns added a comment - I'm just looking for someone to closely inspect the implementation I made, and add some automated test coverage for it. I'm not very confident in the initial implementation.
        Hide
        Manfred Riem added a comment -

        svn commit -m "Added test exercising resources located in /WEB-INF/myresources"
        Adding test\agnostic\resource\relocated\src
        Adding test\agnostic\resource\relocated\src\main
        Adding test\agnostic\resource\relocated\src\main\webapp
        Adding test\agnostic\resource\relocated\src\main\webapp\WEB-INF
        Adding test\agnostic\resource\relocated\src\main\webapp\WEB-INF\glassfish-web.xml
        Adding test\agnostic\resource\relocated\src\main\webapp\WEB-INF\myresources
        Adding test\agnostic\resource\relocated\src\main\webapp\WEB-INF\myresources\default.xhtml
        Adding test\agnostic\resource\relocated\src\main\webapp\WEB-INF\web.xml
        Adding test\agnostic\resource\relocated\src\main\webapp\issue2348.xhtml
        Adding test\agnostic\resource\relocated\src\test
        Adding test\agnostic\resource\relocated\src\test\java
        Adding test\agnostic\resource\relocated\src\test\java\com
        Adding test\agnostic\resource\relocated\src\test\java\com\sun
        Adding test\agnostic\resource\relocated\src\test\java\com\sun\faces
        Adding test\agnostic\resource\relocated\src\test\java\com\sun\faces\test
        Adding test\agnostic\resource\relocated\src\test\java\com\sun\faces\test\agnostic
        Adding test\agnostic\resource\relocated\src\test\java\com\sun\faces\test\agnostic\resource
        Adding test\agnostic\resource\relocated\src\test\java\com\sun\faces\test\agnostic\resource\relocated
        Adding test\agnostic\resource\relocated\src\test\java\com\sun\faces\test\agnostic\resource\relocated\Issue2348IT.java
        Transmitting file data .....
        Committed revision 10176.

        Show
        Manfred Riem added a comment - svn commit -m "Added test exercising resources located in /WEB-INF/myresources" Adding test\agnostic\resource\relocated\src Adding test\agnostic\resource\relocated\src\main Adding test\agnostic\resource\relocated\src\main\webapp Adding test\agnostic\resource\relocated\src\main\webapp\WEB-INF Adding test\agnostic\resource\relocated\src\main\webapp\WEB-INF\glassfish-web.xml Adding test\agnostic\resource\relocated\src\main\webapp\WEB-INF\myresources Adding test\agnostic\resource\relocated\src\main\webapp\WEB-INF\myresources\default.xhtml Adding test\agnostic\resource\relocated\src\main\webapp\WEB-INF\web.xml Adding test\agnostic\resource\relocated\src\main\webapp\issue2348.xhtml Adding test\agnostic\resource\relocated\src\test Adding test\agnostic\resource\relocated\src\test\java Adding test\agnostic\resource\relocated\src\test\java\com Adding test\agnostic\resource\relocated\src\test\java\com\sun Adding test\agnostic\resource\relocated\src\test\java\com\sun\faces Adding test\agnostic\resource\relocated\src\test\java\com\sun\faces\test Adding test\agnostic\resource\relocated\src\test\java\com\sun\faces\test\agnostic Adding test\agnostic\resource\relocated\src\test\java\com\sun\faces\test\agnostic\resource Adding test\agnostic\resource\relocated\src\test\java\com\sun\faces\test\agnostic\resource\relocated Adding test\agnostic\resource\relocated\src\test\java\com\sun\faces\test\agnostic\resource\relocated\Issue2348IT.java Transmitting file data ..... Committed revision 10176.

          People

          • Assignee:
            Manfred Riem
            Reporter:
            Ed Burns
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 2 days
              2d
              Remaining:
              Remaining Estimate - 2 days
              2d
              Logged:
              Time Spent - Not Specified
              Not Specified