[ 
https://issues.apache.org/jira/browse/TAP5-258?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ivan Dubrov updated TAP5-258:
-----------------------------

    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:

<code>
...
@Property(write = false)
@PageActivationContext(activate = false)
private Integer orderId;
...
</code>

Index.tml:

{code:xml}
...
<t:pagelink t:page="orders/index">Broken link</t:pagelink>
<t:pagelink t:page="orders">Correct link<t:pagelink>
...
{code}

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):

{code:java}
        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));
                        }
                };
        }
{code}

  was:
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:

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

Index.tml:

{code:xml}
...
<t:pagelink t:page="orders/index">Broken link</t:pagelink>
<t:pagelink t:page="orders">Correct link<t:pagelink>
...
{code}

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):

{code:java}
        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));
                        }
                };
        }
{code}


> RequestPageCache should canonicalize page name
> ----------------------------------------------
>
>                 Key: TAP5-258
>                 URL: https://issues.apache.org/jira/browse/TAP5-258
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.0.15
>            Reporter: Ivan Dubrov
>
> 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:
> <code>
> ...
> @Property(write = false)
> @PageActivationContext(activate = false)
> private Integer orderId;
> ...
> </code>
> Index.tml:
> {code:xml}
> ...
> <t:pagelink t:page="orders/index">Broken link</t:pagelink>
> <t:pagelink t:page="orders">Correct link<t:pagelink>
> ...
> {code}
> 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):
> {code:java}
>       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));
>                       }
>               };
>       }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to