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

          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          2d 22h 38m 1 Emond Papegaaij 29/Jul/13 11:28
          Martin Grigorov made changes -
          Link This issue breaks WICKET-5366 [ WICKET-5366 ]
          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; }
          Emond Papegaaij made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 7.0.0 [ 12322958 ]
          Fix Version/s 6.10.0 [ 12324643 ]
          Resolution Fixed [ 1 ]
          Hide
          Emond Papegaaij added a comment -

          Fixed

          Show
          Emond Papegaaij added a comment - Fixed
          Martin Grigorov made changes -
          Assignee Emond Papegaaij [ papegaaij ]
          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.
          Tobias Haupt made changes -
          Summary Dependencies of Resource Bundle References are not respected Dependencies of Resource Bundle References are ignored
          Tobias Haupt made changes -
          Field Original Value New Value
          Attachment quickstart_bundle.zip [ 12594376 ]
          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.
          Tobias Haupt created issue -

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development