Wicket
  1. Wicket
  2. WICKET-5291

Dependencies of Resource Bundle References are ignored

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.9.1
    • Fix Version/s: 6.10.0, 7.0.0-M1
    • Component/s: wicket
    • Labels:
      None

      Description

      When several resource references are bundled, the bundle inherits the dependencies of all included resource references. Those dependencies are not evaluated when a header item is created from an included reference and rendered to the response (in ResourceAggregator).

        Issue Links

          Activity

          Hide
          Martin Grigorov added a comment -

          This fix seems to break a use case - org.apache.wicket.markup.head.ResourceAggregator#getItemToBeRendered may return a bundle for a HeaderItem, but if the header item is PriorityHeaderItem then the bundle looses the priority status and later org.apache.wicket.markup.head.PriorityFirstComparator#compare has no information about the priority and doesn't sort properly.

          I have to create a proper unit test but the following change seems to fix the problem with our app:

          — i/wicket-core/src/main/java/org/apache/wicket/markup/head/ResourceAggregator.java
          +++ w/wicket-core/src/main/java/org/apache/wicket/markup/head/ResourceAggregator.java
          @@ -400,6 +400,19 @@ public class ResourceAggregator extends DecoratingHeaderResponse
          }

          HeaderItem bundle = Application.get().getResourceBundles().findBundle(innerItem);

          • return bundle == null ? item : bundle;
            + HeaderItem itemToBeRendered;
            + if (bundle == null)
            + { + itemToBeRendered = item; + }

            + else if (item instanceof PriorityHeaderItem)
            +

            { + itemToBeRendered = new PriorityHeaderItem(bundle); + }

            + else
            +

            { + itemToBeRendered = bundle; + }

            + return itemToBeRendered;
            }

          Show
          Martin Grigorov added a comment - This fix seems to break a use case - org.apache.wicket.markup.head.ResourceAggregator#getItemToBeRendered may return a bundle for a HeaderItem, but if the header item is PriorityHeaderItem then the bundle looses the priority status and later org.apache.wicket.markup.head.PriorityFirstComparator#compare has no information about the priority and doesn't sort properly. I have to create a proper unit test but the following change seems to fix the problem with our app: — i/wicket-core/src/main/java/org/apache/wicket/markup/head/ResourceAggregator.java +++ w/wicket-core/src/main/java/org/apache/wicket/markup/head/ResourceAggregator.java @@ -400,6 +400,19 @@ public class ResourceAggregator extends DecoratingHeaderResponse } HeaderItem bundle = Application.get().getResourceBundles().findBundle(innerItem); return bundle == null ? item : bundle; + HeaderItem itemToBeRendered; + if (bundle == null) + { + itemToBeRendered = item; + } + else if (item instanceof PriorityHeaderItem) + { + itemToBeRendered = new PriorityHeaderItem(bundle); + } + else + { + itemToBeRendered = bundle; + } + return itemToBeRendered; }
          Hide
          Emond Papegaaij added a comment -

          Fixed

          Show
          Emond Papegaaij added a comment - Fixed
          Hide
          Tobias Haupt added a comment - - edited

          In ResourceAggregator every recorded item will be rendered in the specified order (child first, filtering etc.). When an item is recorded, the dependencies are recorded first.

          The bundle resolving is triggered later, when all recorded items will be rendered to the real response. In getItemToBeRendered(HeaderItem item) items that belong to a bundle are replaced with that bundle. This may result in a bundle beeing rendered before all dependencies of the inculded items are rendered.

          Bundles should be searched for at recording time, not at real rendering time.

          Show
          Tobias Haupt added a comment - - edited In ResourceAggregator every recorded item will be rendered in the specified order (child first, filtering etc.). When an item is recorded, the dependencies are recorded first. The bundle resolving is triggered later, when all recorded items will be rendered to the real response. In getItemToBeRendered(HeaderItem item) items that belong to a bundle are replaced with that bundle. This may result in a bundle beeing rendered before all dependencies of the inculded items are rendered. Bundles should be searched for at recording time, not at real rendering time.
          Hide
          Tobias Haupt added a comment -

          The quickstart shows a page with 2 components on it. Each of the component references a css resource which itself has a dependency to an aditional css resource (that allways should be rendered first). If both divs (one for each panel) are rendered GREEN, the dependencies are in the correct order. If one is rendered RED, the order is not as defined.
          A resource bundle is created in the web application that concats the two primary css resources into one file. If the bundle is not registered, everything works fine.

          Show
          Tobias Haupt added a comment - The quickstart shows a page with 2 components on it. Each of the component references a css resource which itself has a dependency to an aditional css resource (that allways should be rendered first). If both divs (one for each panel) are rendered GREEN, the dependencies are in the correct order. If one is rendered RED, the order is not as defined. A resource bundle is created in the web application that concats the two primary css resources into one file. If the bundle is not registered, everything works fine.

            People

            • Assignee:
              Emond Papegaaij
              Reporter:
              Tobias Haupt
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development