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

Martin Grigorov resolved WICKET-5558.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 6.15.0
                   7.0.0
         Assignee: Martin Grigorov

Thanks for the investigation and the patch!

> Autolinking does not always work in inheritted markup
> -----------------------------------------------------
>
>                 Key: WICKET-5558
>                 URL: https://issues.apache.org/jira/browse/WICKET-5558
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 6.14.0
>            Reporter: Jesse Long
>            Assignee: Martin Grigorov
>             Fix For: 7.0.0, 6.15.0
>
>         Attachments: WICKET-5558.patch, quickstart.tar.gz
>
>
> If you have auto-linked auto components that point to package resource, like:
> {noformat}
> <wicket:link><img src="myimage.png"/></wicket:link>
> {noformat}
> defined in the grandparent markup, where the grandparent and parent are from 
> different packages, then they do get rendered correctly.
> Problem is this: AutoLinkResolver checks that the package resource actually 
> exists. It checks by creating a PackageResourceReference and attempts to get 
> the reference from that. The class used as the context for the 
> PackageResourceReference is the class which owns the markup in which the 
> auto-link appeared. The key is the original reference (href or src) in the 
> tag. So far everything is correct.
> Wicket knows which class owned the markup by using 
> ComponentTag#getMarkupClass(). It is therefore important that 
> ComponentTag#getMarkupClass() always returns the correct class. But it 
> doesn't.
> When we have a three level merged markup (child, parent, grandparent), this 
> happens: parent markup is merged into grandparent using MergedMarkup. All 
> ComponentTags that were originally from grandparent are called 
> :#setMarkupClass(GrandParent.class), so that they will know they came from 
> the grandparent. So far so good.
> Now, in order to get the child markup stream, we merge child markup onto the 
> parent markup. Now, all ComponentTags in the parent markup are 
> setMarkupClass(Parent.class). Problem is, this is not true. Some of these 
> ComponentTags actually came from the grandparent, so the ComponentTag ends up 
> returning the incorrect class (Parent.class instead of GrandParent.class) in 
> #getMarkupClass().
> Because ComponentTag#getMarkupClass() can return the wrong value, if the 
> Parent and GrandParent are in different packages, then a resource that would 
> be loadable by the grandparent is no longer loadable, because we are using 
> the parent, which cannot find it.
> Solution, fix MergedMarkup to only setMarkupClass() if getMarkupClass() == 
> null.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to