Tapestry 5
  1. Tapestry 5
  2. TAP5-258

RequestPageCache should canonicalize page name

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.15
    • Fix Version/s: 5.0.16
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      Since the RequestPageCache does not canonicalize the page name, there is a possibility that same page will be put into page cache twice, one time with canonical name and second time with non-canonical.

      For example, I have a "Index" page in the orders package. When I open the "/app/orders" page, the Page instance is put into the RequestPageCache under the "orders" key. So when I get the Page from the cache by requestPageCache.get(resources.getPageName()), I get different Page instance (since resources.getPageName() returns canonicalized page name, which is "/app/orders/index").

      This could lead to loss of activation parameter. Example:

      Index.java:

      ...
      @Property(write = false)
      @PageActivationContext(activate = false)
      private Integer orderId;
      ...

      Index.tml:

      ...
      <t:pagelink t:page="orders/index">Broken link</t:pagelink>
      <t:pagelink t:page="orders">Correct link<t:pagelink>
      ...

      If you open page /app/orders/123, the first link will be just "/app/orders" and second will be "/orders/123" (correct one).

      The following snippet shows how this could be fixed now (the idea is to canonicalize page name before retrieving it from the cache):

      public static RequestPageCache decorateRequestPageCache(
      Class<RequestPageCache> serviceInterface, final RequestPageCache delegate,
      String serviceId, final ComponentClassResolver resolver) {
      return new RequestPageCache() {
      public Page get(String logicalPageName)

      { return delegate.get(resolver.canonicalizePageName(logicalPageName)); }

      };
      }

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Ivan Dubrov
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development