Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.2
    • Component/s: Components/Renderers
    • Labels:
      None
    • Environment:

      All

      Description

      If I have an h:outputLink with a value containing spaces, it is rendered with the spaces converted to +.

      It seems to me that if it is going to convert this at all, it should do so correctly, i.e. to %20. Alternatively it should leave it alone and let it fail as originally supplied.

      Am I missing something here?

      I have a legacy content database where the document index provides URLs contain spaces. I can change that, and probably will, but maybe this is a bug and will get fixed the way I would like?

      Discussion <a href="http://forums.oracle.com/forums/thread.jspa?messageID=9639501&#9639501">here</a>. Appears to involve use of URLEncoder for the one thing it cannot do, which is encode a URL. Should be using URI.toASCIIString().

        Issue Links

          Activity

          ejp created issue -
          Ed Burns made changes -
          Field Original Value New Value
          Status Open [ 1 ] In Progress [ 3 ]
          Hide
          Ed Burns added a comment -

          You are correct in filing this as a spec issue, because the problem stems from the specification for the renderer for javax.faces.Output javax.faces.Link.

          http://javaserverfaces.java.net/nonav/docs/2.1/renderkitdocs/index.html

          The entire "href" string must be passed through a call to the encodeResourceURL() method of the ExternalContext.

          Which ends up calling: javax.servlet.http.HttpServletResponse method encodeURL(url).

          Show
          Ed Burns added a comment - You are correct in filing this as a spec issue, because the problem stems from the specification for the renderer for javax.faces.Output javax.faces.Link. http://javaserverfaces.java.net/nonav/docs/2.1/renderkitdocs/index.html The entire "href" string must be passed through a call to the encodeResourceURL() method of the ExternalContext. Which ends up calling: javax.servlet.http.HttpServletResponse method encodeURL(url).
          Ed Burns logged work - 17/Jun/11 1:54 PM
          • Time Spent:
            20 minutes
             
            <No comment>
          Ed Burns made changes -
          Remaining Estimate 0 minutes [ 0 ]
          Time Spent 20 minutes [ 1200 ]
          Ed Burns made changes -
          Hide
          Ed Burns added a comment -

          checkpoint

          Show
          Ed Burns added a comment - checkpoint
          Ed Burns made changes -
          Attachment 20110617_i_spec_1019.patch [ 46364 ]
          Ed Burns logged work - 17/Jun/11 2:48 PM
          • Time Spent:
            53 minutes
             
            <No comment>
          Ed Burns made changes -
          Time Spent 20 minutes [ 1200 ] 1 hour, 13 minutes [ 4380 ]
          Hide
          Ed Burns added a comment -

          Sending jsf-api/doc/standard-html-renderkit-base.xml
          Sending jsf-api/doc/standard-html-renderkit.xml
          Sending jsf-api/src/main/java/javax/faces/context/ResponseWriter.java
          Sending jsf-ri/src/main/java/com/sun/faces/util/HtmlUtils.java
          Sending jsf-ri/systest/build-tests.xml
          Adding jsf-ri/systest/web/render/outputLinkSpaces.jsp
          Sending jsf-tools/src/main/resources/com/sun/faces/generate/facesdoc/stylesheet.css
          Transmitting file data .......
          Committed revision 9175.

          Show
          Ed Burns added a comment - Sending jsf-api/doc/standard-html-renderkit-base.xml Sending jsf-api/doc/standard-html-renderkit.xml Sending jsf-api/src/main/java/javax/faces/context/ResponseWriter.java Sending jsf-ri/src/main/java/com/sun/faces/util/HtmlUtils.java Sending jsf-ri/systest/build-tests.xml Adding jsf-ri/systest/web/render/outputLinkSpaces.jsp Sending jsf-tools/src/main/resources/com/sun/faces/generate/facesdoc/stylesheet.css Transmitting file data ....... Committed revision 9175.
          Ed Burns made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Fix Version/s 2.2 [ 10403 ]
          Resolution Fixed [ 1 ]
          Hide
          ejp added a comment -

          As a workaround until this fix is released, you can add the following converter to the h:outputLink element:

          public class URLConverter implements Converter
          {
          @Override
          public Object getAsObject(FacesContext fc, UIComponent uic, String string)

          { return string; }

          @Override
          public String getAsString(FacesContext fc, UIComponent uic, Object object)
          {
          String path = object.toString();
          try

          { if (path.indexOf(' ') >= 0) path = new URI(null, path, null).toASCIIString(); }

          catch (URISyntaxException exc)

          { // logger.log(Level.SEVERE, "uri="+path, exc); }

          return path;
          }
          }

          Show
          ejp added a comment - As a workaround until this fix is released, you can add the following converter to the h:outputLink element: public class URLConverter implements Converter { @Override public Object getAsObject(FacesContext fc, UIComponent uic, String string) { return string; } @Override public String getAsString(FacesContext fc, UIComponent uic, Object object) { String path = object.toString(); try { if (path.indexOf(' ') >= 0) path = new URI(null, path, null).toASCIIString(); } catch (URISyntaxException exc) { // logger.log(Level.SEVERE, "uri="+path, exc); } return path; } }
          Ed Burns made changes -
          Component/s Components/Renderers [ 10216 ]
          Hide
          ejp added a comment - - edited

          The same problem also turns up in h:graphicImage. For example:

          h:graphicImage value="{{lab.path}}VisualObjective.jpg" where lab.path evaluates to /cLabsTest/EDSILabs/vLearning/Cisco Courses/Enterprise (Routers & Switches)/Interconnecting Cisco Network Devices 1/ICND1 Lab 2-2 Performing Switch Startup and Initial Configuration/VisualObjective.jpg

          becomes

          img src="/cLabsTest/EDSILabs/vLearning/Cisco+Courses/Enterprise+(Routers+&+Switches)/Interconnecting+Cisco+Network+Devices+1/ICND1+Lab+2-2+Performing+Switch+Startup+and+Initial+Configuration/VisualObjective.jpg"

          Should I report this as a new bug?

          Show
          ejp added a comment - - edited The same problem also turns up in h:graphicImage. For example: h:graphicImage value="{{lab.path}}VisualObjective.jpg" where lab.path evaluates to /cLabsTest/EDSILabs/vLearning/Cisco Courses/Enterprise (Routers & Switches)/Interconnecting Cisco Network Devices 1/ICND1 Lab 2-2 Performing Switch Startup and Initial Configuration/VisualObjective.jpg becomes img src="/cLabsTest/EDSILabs/vLearning/Cisco+Courses/Enterprise+(Routers+&+Switches)/Interconnecting+Cisco+Network+Devices+1/ICND1+Lab+2-2+Performing+Switch+Startup+and+Initial+Configuration/VisualObjective.jpg" Should I report this as a new bug?
          Hide
          Manfred Riem added a comment -

          Closing resolved issue out

          Show
          Manfred Riem added a comment - Closing resolved issue out
          Manfred Riem made changes -
          Status Resolved [ 5 ] Closed [ 6 ]

            People

            • Assignee:
              Ed Burns
              Reporter:
              ejp
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 13 minutes
                1h 13m