ICEfaces
  1. ICEfaces
  2. ICE-3857

OutputResource: Display correct URL when attachment="false"

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.2
    • Fix Version/s: 1.8DR#2, 1.8
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      All

      Description

      When using the outputResource component to display pdfs, if attachement="true" the filename will be appended to the URL when the user selects save. If attachment="false", the filename is not included in the generated URL.

      i.e:

      http://localhost/testApp/Web/block/resource/LTE4NTk2MjU0MzQ=/filename.pdf

      instead of just

      http://localhost/testApp/Web/block/resource/LTE4NTk2MjU0MzQ=/

       

        Activity

        Tyler Johnson created issue -
        Hide
        Tyler Johnson added a comment -

        Here is the fix for ResourceDispatcher.java:

        private class FileNameOption implements Resource.Options {
        private String fileName;
        public String getFileName()

        { return fileName; }

        public void setAsAttachement()

        { // TODO Auto-generated method stub }
        public void setExpiresBy(Date date) { // TODO Auto-generated method stub }

        public void setFileName(String fileName)

        { this.fileName = fileName; }

        public void setLastModified(Date date)

        { // TODO Auto-generated method stub }
        public void setMimeType(String mimeType) { // TODO Auto-generated method stub }

        }
        public URI registerResource(Resource resource, ResourceLinker.Handler handler) {
        if( handler == null )
        handler = NOOPHandler;
        final FileNameOption options = new FileNameOption();
        try

        { resource.withOptions(options); }

        catch (IOException e)

        { throw new RuntimeException(e); }

        final String filename = options.getFileName();
        final String name = prefix + encode(resource) + "/" + (filename != null && filename != "" ? filename : "");

        Show
        Tyler Johnson added a comment - Here is the fix for ResourceDispatcher.java: private class FileNameOption implements Resource.Options { private String fileName; public String getFileName() { return fileName; } public void setAsAttachement() { // TODO Auto-generated method stub } public void setExpiresBy(Date date) { // TODO Auto-generated method stub } public void setFileName(String fileName) { this.fileName = fileName; } public void setLastModified(Date date) { // TODO Auto-generated method stub } public void setMimeType(String mimeType) { // TODO Auto-generated method stub } } public URI registerResource(Resource resource, ResourceLinker.Handler handler) { if( handler == null ) handler = NOOPHandler; final FileNameOption options = new FileNameOption(); try { resource.withOptions(options); } catch (IOException e) { throw new RuntimeException(e); } final String filename = options.getFileName(); final String name = prefix + encode(resource) + "/" + (filename != null && filename != "" ? filename : "");
        Tyler Johnson made changes -
        Field Original Value New Value
        Salesforce Case [50070000007CKUL]
        Tyler Johnson made changes -
        Assignee Ken Fyten [ ken.fyten ]
        Ken Fyten made changes -
        Fix Version/s 1.8DR#2 [ 10142 ]
        Assignee Priority P2
        Assignee Ken Fyten [ ken.fyten ] Yip Ng [ yip.ng ]
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #18008 Tue Dec 09 14:20:36 MST 2008 yip.ng ICE-3857
        Added file name to generated URL.
        Files Changed
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/http/core/ResourceDispatcher.java
        Hide
        yip.ng added a comment -

        The attachment attribute doesn't affect the generation of the URL. The same URL is generated regardless. The attachment attribute determines whether a save file dialog will pop up right away when a link is left-clicked. If true, a save file dialog will pop up, and the file name will be taken from the filename attribute in the Content-Disposition HTTP header, NOT from the URL. If false, you have to right-click and choose Save Link As to save the file. Then the file name is taken from the generated URL.

        Show
        yip.ng added a comment - The attachment attribute doesn't affect the generation of the URL. The same URL is generated regardless. The attachment attribute determines whether a save file dialog will pop up right away when a link is left-clicked. If true, a save file dialog will pop up, and the file name will be taken from the filename attribute in the Content-Disposition HTTP header, NOT from the URL. If false, you have to right-click and choose Save Link As to save the file. Then the file name is taken from the generated URL.
        Hide
        yip.ng added a comment -

        The problem is not specific to PDF files. It occurs in every type of file.

        Show
        yip.ng added a comment - The problem is not specific to PDF files. It occurs in every type of file.
        Hide
        yip.ng added a comment -

        Suggested fix applied, but note that there is a bug in the supplied code: filename != "" should be !filename.equals(""). This has been changed.

        Show
        yip.ng added a comment - Suggested fix applied, but note that there is a bug in the supplied code: filename != "" should be !filename.equals(""). This has been changed.
        yip.ng made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Adnan Durrani made changes -
        Link This issue depends on ICE-3869 [ ICE-3869 ]
        Hide
        Keith Garry Boyce added a comment -

        We encountered another issue with this fix... If there are space's in filename then the URI generates an error as being invalid. Hence the URL has to be urlencoded.. But when urlencoding the filename the pattern matcher complains about + and - characters which need to be escaped in pattern matching algorithm on registering resource..

        Please address this test case as well.. i.e where filename has spaces and dashes... and also think about the other valid characters that may be in a filename

        Show
        Keith Garry Boyce added a comment - We encountered another issue with this fix... If there are space's in filename then the URI generates an error as being invalid. Hence the URL has to be urlencoded.. But when urlencoding the filename the pattern matcher complains about + and - characters which need to be escaped in pattern matching algorithm on registering resource.. Please address this test case as well.. i.e where filename has spaces and dashes... and also think about the other valid characters that may be in a filename
        yip.ng made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #18090 Thu Dec 18 15:45:51 MST 2008 yip.ng ICE-3857
        Changed to encode URL file name of resource and make the resource registry pattern matching still work with the encoded URL.
        Files Changed
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/http/core/ResourceDispatcher.java
        yip.ng made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Sam Xiao added a comment -

        test

        Show
        Sam Xiao added a comment - test
        Sam Xiao made changes -
        Attachment test.jpg [ 11421 ]
        Sam Xiao made changes -
        Attachment test.jpg [ 11421 ]
        yip.ng made changes -
        Attachment ScreenHunter_01 Dec. 19 10.12.jpg [ 11422 ]
        Ken Fyten made changes -
        Fix Version/s 1.8 [ 10161 ]
        Assignee Priority P2
        Ken Fyten made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Assignee Yip Ng [ yip.ng ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved: