javaserverfaces-spec-public
  1. javaserverfaces-spec-public
  2. JAVASERVERFACES_SPEC_PUBLIC-946

Provide internal server path of resources from Resource API via EL

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.0, 2.1
    • Fix Version/s: None
    • Component/s: EL, Resources
    • Labels:
      None
    • Status Whiteboard:
      Hide

      size_small importance_medium

      Show
      size_small importance_medium

      Description

      Currently JSF 2 provides #

      {resource['libraryName:resourceName']}

      to get the request path of the specified resource for the browser (e.g. /context-root/faces/javax.faces.resource/libraryName/resourceName). Thus #

      {resource[...]}

      is mostly used for css or js files.

      Unfortunately there is no way to use the Resource API directly in EL to get the server path to internal resources, e.g. when using <ui:include src="..."> and referrencing a xhtml (facelet) page.

      Of course, as a workaround, you can use this method in a managed bean:

      public String getMyResourcePath()
      {
      FacesContext facesContext = FacesContext.getCurrentInstance();

      Resource resource = facesContext.getApplication().getResourceHandler()
      .createResource("myresource.xhtml", "mylibrary");
      URL url = resource.getURL();

      return url.toExternalForm();
      }

      However, this really only is a workaround.

      I'd like to propose using #

      {serverresource['...']}

      or #

      {internalresource['...']}

      or #

      {resoure['...'].serverPath}

      (or something similar) to provide a convenient way for getting the server-path to the resource. This way users can use the facelets templating mechanism in combination with the Resource API, e.g.:

      <ui:include src="#

      {serverresource['templates:headInclude.xhtml']}

      " />
      <ui:component template="#

      {serverresource['templates:componentTemplate.xhtml']}

      ">
      ...

      See also the user-discussion from the MyFaces mailing list (showing that users are confused why #

      {resource['']}

      isn't working for facelets stuff): http://www.mail-archive.com/users@myfaces.apache.org/msg56907.html

        Activity

        Jakob Korherr created issue -
        Ed Burns made changes -
        Field Original Value New Value
        Status Whiteboard size_small importance_medium
        Ed Burns made changes -
        Assignee rogerk [ rogerk ]
        Hide
        Ed Burns added a comment -

        Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.

        Show
        Ed Burns added a comment - Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.
        Ed Burns made changes -
        Priority Major [ 3 ] Trivial [ 5 ]
        Ed Burns made changes -
        Priority Trivial [ 5 ] Minor [ 4 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Jakob Korherr
          • Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: