javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-2153

outputStylesheet with suffix mapping appends suffix to resources unlike <link href="">

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Incomplete
    • Affects Version/s: 2.1.1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Glassfish 3.1/Mojarra 2.1.2

      Description

      I changed from prefix to suffix mapping (/faces/* to *.xhtml) in deployment
      descriptor:

      <servlet-mapping>
      <servlet-name>Faces Servlet</servlet-name>
      <url-pattern>*.xhtml</url-pattern>
      </servlet-mapping>

      I notice that when loading resources with outputStylesheet that in the
      below example the browser is requesting the resource styles.css.xhtml. The
      servlet finds the styles.css resource ok, the issue is that within the
      stylesheet you have to append .xhtml to any url() references (i.e. on
      background-image).

      This is not the end of the world but it is far from intuitive and doesn't
      happen when loading a stylesheet with link href. The problem is how to fix
      it without breaking backwards compatibility I imagine.

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets">
      <h:head>
      <title>Facelet Title</title>
      <ui:remove>
      <link type="text/css" rel="stylesheet" href="#

      {request.contextPath}

      /resources/styles.css"/>
      </ui:remove>
      <h:outputStylesheet name="styles.css"/>
      </h:head>
      <h:body>
      <h:outputText styleClass="fred" value="Hello"/>
      </h:body>
      </html>

        Activity

        Hide
        oversteer added a comment -

        BalusC has pointed out that you don't have to append the suffix if
        you specify a resource in the following format:

        stylesheet.css
        --------------
        background-image: url("#

        {resource['images:background265.png']}

        ");

        instead of:

        background-image: url(images/background265.png.xhtml);

        but this convoluted syntax is clearly a million miles away from being
        intuitive, but it has the big advantage that the resource references
        do not need to be modified in the event that you change the servlet
        mapping suffix.

        Show
        oversteer added a comment - BalusC has pointed out that you don't have to append the suffix if you specify a resource in the following format: stylesheet.css -------------- background-image: url("# {resource['images:background265.png']} "); instead of: background-image: url(images/background265.png.xhtml); but this convoluted syntax is clearly a million miles away from being intuitive, but it has the big advantage that the resource references do not need to be modified in the event that you change the servlet mapping suffix.
        Hide
        Manfred Riem added a comment -

        Have you tried using 2 Faces mappings (.xhtml and /faces/) ?

        Show
        Manfred Riem added a comment - Have you tried using 2 Faces mappings ( .xhtml and /faces/ ) ?
        Hide
        Manfred Riem added a comment -

        Lowering priority because of no response

        Show
        Manfred Riem added a comment - Lowering priority because of no response
        Hide
        Manfred Riem added a comment -

        Lowering priority because of no response

        Show
        Manfred Riem added a comment - Lowering priority because of no response
        Hide
        Manfred Riem added a comment -

        Closing because of inactivity

        Show
        Manfred Riem added a comment - Closing because of inactivity

          People

          • Assignee:
            Unassigned
            Reporter:
            oversteer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: