javaeetutorial
  1. javaeetutorial
  2. JAVAEETUTORIAL-49

Relocatable resources aren't documented in the JSF chapters

    Details

    • Type: Task Task
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.0.7
    • Fix Version/s: 6.0.7
    • Component/s: doc
    • Labels:
      None

      Description

      JSF 2.0 has the ability to package resources into reusable libraries, and refer to resources in these libraries using a resource identifier syntax. This feature isn't documented in the JSF chapters of the Tutorial.

      See section 2.6.1, "Packaging Resources," of the JSF 2.0 spec.

      In addition to resources in the web app root's resources directory, e.g.:
      web/resources/css/local.css

      You can package a JAR file within the WAR that contains the following structure:
      META-INF/resources/css/external.css

      You can then refer to the CSS files as follows:
      <h:head>
      <h:outputStylesheet name="#

      {resource['css/local.css']}

      " />
      <h:outputStylesheet name="#

      {resource['css/external.css']}

      " />
      </h:head>

        Issue Links

          Activity

          Hide
          Kim Haase added a comment -

          My understanding is that strictly speaking, the term "relocatable resource" refers to the fact that you can include a resource reference in one place on the page (say, the body) and specify another location for it, like the head, using the target attribute. This is described in Section 2.6.2.1 of the JSF 2.1 spec.

          The section http://download.oracle.com/javaee/6/tutorial/doc/bnarf.html#gjgep discusses this subject, including specifying the target as "#

          {param.location}

          " to make the resource dynamically relocatable.

          Packaging resources into libraries does need further documentation beyond what is in http://download.oracle.com/javaee/6/tutorial/doc/girgm.html, but that's not the same thing as relocatable resources. Should the issue be retitled, say to "Packaging resource libraries isn't documented ...."?

          Another issue: I have trouble getting this syntax to work:

          <h:outputStylesheet name="#

          {resource['css/local.css']}

          " />

          According to the spec, you have to say

          <h:outputStylesheet name="#

          {resource['css:local.css']}

          " />

          However, neither seems to work, at least for stylesheets. With both, the generated HTML has

          <link type="text/css" rel="stylesheet" href="RES_NOT_FOUND" />

          The server has the following warning for both:

          WARNING: JSF1091: No mime type could be found for file /guessnumber/faces/javax.faces.resource/default.css?ln=css. To resolve this, add a mime-type mapping to the applications web.xml.

          The library/name attributes work fine, though:

          <h:outputStylesheet library="css" name="local.css" />

          Show
          Kim Haase added a comment - My understanding is that strictly speaking, the term "relocatable resource" refers to the fact that you can include a resource reference in one place on the page (say, the body) and specify another location for it, like the head, using the target attribute. This is described in Section 2.6.2.1 of the JSF 2.1 spec. The section http://download.oracle.com/javaee/6/tutorial/doc/bnarf.html#gjgep discusses this subject, including specifying the target as "# {param.location} " to make the resource dynamically relocatable. Packaging resources into libraries does need further documentation beyond what is in http://download.oracle.com/javaee/6/tutorial/doc/girgm.html , but that's not the same thing as relocatable resources. Should the issue be retitled, say to "Packaging resource libraries isn't documented ...."? Another issue: I have trouble getting this syntax to work: <h:outputStylesheet name="# {resource['css/local.css']} " /> According to the spec, you have to say <h:outputStylesheet name="# {resource['css:local.css']} " /> However, neither seems to work, at least for stylesheets. With both, the generated HTML has <link type="text/css" rel="stylesheet" href="RES_NOT_FOUND" /> The server has the following warning for both: WARNING: JSF1091: No mime type could be found for file /guessnumber/faces/javax.faces.resource/default.css?ln=css. To resolve this, add a mime-type mapping to the applications web.xml. The library/name attributes work fine, though: <h:outputStylesheet library="css" name="local.css" />
          Hide
          Kim Haase added a comment -

          It may be that the reason you can use the square-bracket resource identifier syntax with a graphicImage tag but not with outputStylesheet or outputScript may be that the square-bracket syntax is a ValueExpression that evaluates to an Object, the required argument for the graphicImage tag's value attribute. The required name attribute of outputStylesheet and outputScript takes a ValueExpression that evaluates to a String.

          Show
          Kim Haase added a comment - It may be that the reason you can use the square-bracket resource identifier syntax with a graphicImage tag but not with outputStylesheet or outputScript may be that the square-bracket syntax is a ValueExpression that evaluates to an Object, the required argument for the graphicImage tag's value attribute. The required name attribute of outputStylesheet and outputScript takes a ValueExpression that evaluates to a String.
          Hide
          Kim Haase added a comment -

          I have added much of this information to the "Facelets" and "Using JavaServer Faces Technology in Web Pages" chapters but am planning to save the information about packaging resources in JAR files for the chapter on the Duke's Forest example. There is no logical place to put it in the existing advanced JSF chapters, I think.

          Show
          Kim Haase added a comment - I have added much of this information to the "Facelets" and "Using JavaServer Faces Technology in Web Pages" chapters but am planning to save the information about packaging resources in JAR files for the chapter on the Duke's Forest example. There is no logical place to put it in the existing advanced JSF chapters, I think.
          Hide
          Kim Haase added a comment -

          In the Facelets chapter, added an additional sentence and a forward reference (combined tutorial only) to the Duke's Forest chapter.

          Show
          Kim Haase added a comment - In the Facelets chapter, added an additional sentence and a forward reference (combined tutorial only) to the Duke's Forest chapter.
          Hide
          Kim Haase added a comment -

          Documented feature in Facelets chapter, checked in to workspace. If more is needed, please let me know.

          Show
          Kim Haase added a comment - Documented feature in Facelets chapter, checked in to workspace. If more is needed, please let me know.

            People

            • Assignee:
              Kim Haase
              Reporter:
              Ian Evans
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: