Tapestry 5
  1. Tapestry 5
  2. TAP5-1483

AssetPathConstructorImpl should use BaseURLSource

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 5.2
    • Fix Version/s: 5.3
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      Asset paths should be constructed using the BaseURLSource rather than just the request context path to match the behavior for pages, etc. Currently, to get absolute URL's including domain portion for assets, you need to override the AssetPathConstructor.

      Apart from contributing the BaseURLSource, it is a small change from:
      StringBuilder builder = new StringBuilder(request.getContextPath());
      to
      StringBuilder builder = new StringBuilder(baseURLSource.getBaseURL(request.isSecure()));
      builder.append(request.getContextPath());

      1. patch.txt
        2 kB
        Jonathan Barker

        Activity

        Jonathan Barker created issue -
        Hide
        Jonathan Barker added a comment -

        Patch

        Show
        Jonathan Barker added a comment - Patch
        Jonathan Barker made changes -
        Field Original Value New Value
        Attachment patch.txt [ 12474418 ]
        Hide
        Howard M. Lewis Ship added a comment -

        Just trying to figure out why this is necessary ... whta's your scenario where very URL needs to be fully qualified with hostname? Surely, one would think that getting the page request URLs to be fully qualified, with the asset URLs relative to those page request URLs, should be sufficient?

        Show
        Howard M. Lewis Ship added a comment - Just trying to figure out why this is necessary ... whta's your scenario where very URL needs to be fully qualified with hostname? Surely, one would think that getting the page request URLs to be fully qualified, with the asset URLs relative to those page request URLs, should be sufficient?
        Hide
        Jonathan Barker added a comment -

        The use case is a Facebook app where any image needs to have an absolute URL. Specifically, this was an app for a profile or page Tab. The img tags generated errors that relative URL's were not allowed here. I am guessing that it has to do with their caching. I also started developing in production mode to avoid a proliferation of images, css and js files in their caches.

        Show
        Jonathan Barker added a comment - The use case is a Facebook app where any image needs to have an absolute URL. Specifically, this was an app for a profile or page Tab. The img tags generated errors that relative URL's were not allowed here. I am guessing that it has to do with their caching. I also started developing in production mode to avoid a proliferation of images, css and js files in their caches.
        Hide
        Howard M. Lewis Ship added a comment -

        Since this is behavior that most people will not want, I think it will need to be configurable, and default off.

        Show
        Howard M. Lewis Ship added a comment - Since this is behavior that most people will not want, I think it will need to be configurable, and default off.
        Howard M. Lewis Ship made changes -
        Affects Version/s 5.2 [ 12313900 ]
        Affects Version/s 5.2.4 [ 12315557 ]
        Massimo Lusetti made changes -
        Assignee Massimo Lusetti [ mlusetti ]
        Hide
        Hudson added a comment -

        Integrated in tapestry-trunk-freestyle #610 (See https://builds.apache.org/job/tapestry-trunk-freestyle/610/)
        TAP5-1483 Make configuration knob to use of BaseURLSource to build fully qualified Assets URL, defaults to false

        mlusetti : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1189123
        Files :

        • /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
        • /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/AssetPathConstructorImpl.java
        • /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/assets/AssetsModule.java
        • /tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClasspathAssetAliasManagerImplTest.java
        • /tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ContextAssetFactoryTest.java
        • /tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java
        Show
        Hudson added a comment - Integrated in tapestry-trunk-freestyle #610 (See https://builds.apache.org/job/tapestry-trunk-freestyle/610/ ) TAP5-1483 Make configuration knob to use of BaseURLSource to build fully qualified Assets URL, defaults to false mlusetti : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1189123 Files : /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/AssetPathConstructorImpl.java /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/assets/AssetsModule.java /tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ClasspathAssetAliasManagerImplTest.java /tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ContextAssetFactoryTest.java /tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java
        Massimo Lusetti made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 5.3 [ 12316024 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Massimo Lusetti
            Reporter:
            Jonathan Barker
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development