Class ResourceBundles

java.lang.Object
org.apache.wicket.ResourceBundles

public class ResourceBundles extends Object
Contains all resource bundles that are registered in the application. Resource bundles provide a way to combine multiple resources into one, reducing the number of requests needed to load a page. The code using the resources does not need to know about the registered resources, making it possible to create resource bundles for 3rd party libraries. When a single resource from a resource bundle is requested, the bundle is rendered instead. All other resources from the bundle are marked as rendered. A specific resource can only be part of one bundle.
Author:
papegaaij
  • Constructor Details

  • Method Details

    • addJavaScriptBundle

      Adds a javascript bundle that is automatically generated by concatenating the given package resources. If the given resources depend on each other, you should make sure that the resources are provided in the order they need to be concatenated. If the resources depend on other resources, that are not part of the bundle, the bundle will inherit these dependencies. This method is equivalent to addBundle(HeaderItem) with a JavaScriptHeaderItem for a ConcatResourceBundleReference.
      Parameters:
      scope - The scope of the bundle
      name - The name of the resource. This will show up as the filename in the markup.
      references - The resources this bundle will consist of.
      Returns:
      the newly created bundle
    • addJavaScriptBundle

      public JavaScriptReferenceHeaderItem addJavaScriptBundle(Class<?> scope, String name, boolean defer, JavaScriptResourceReference... references)
      Adds a javascript bundle that is automatically generated by concatenating the given package resources. If the given resources depend on each other, you should make sure that the resources are provided in the order they need to be concatenated. If the resources depend on other resources, that are not part of the bundle, the bundle will inherit these dependencies. This method is equivalent to addBundle(HeaderItem) with a JavaScriptHeaderItem for a ConcatResourceBundleReference.
      Parameters:
      scope - The scope of the bundle
      defer - specifies that the execution of a script should be deferred (delayed) until after the page has been loaded.
      name - The name of the resource. This will show up as the filename in the markup.
      references - The resources this bundle will consist of.
      Returns:
      the newly created bundle
    • addCssBundle

      public CssReferenceHeaderItem addCssBundle(Class<?> scope, String name, CssResourceReference... references)
      Adds a css bundle that is automatically generated by concatenating the given package resources. If the given resources depend on each other, you should make sure that the resources are provided in the order they need to be concatenated. If the resources depend on other resources, that are not part of the bundle, the bundle will inherit these dependencies. This method is equivalent to addBundle(HeaderItem) with a CssHeaderItem for a ConcatResourceBundleReference.
      Parameters:
      scope - The scope of the bundle
      name - The name of the resource. This will show up as the filename in the markup.
      references - The resources this bundle will consist of.
      Returns:
      the newly created bundle
    • newBundleResourceReference

      Creates a ResourceReference that will point to the bundle with the items
      Type Parameters:
      T - The type of the header items
      Parameters:
      scope - The scope of the bundle
      name - The name of the resource. This will show up as the filename in the markup.
      items - The HeaderItems for the resource references for the bundle
      Returns:
      A ResourceReference that will point to the bundle with the items
    • addBundle

      public <T extends HeaderItem> T addBundle(T bundle)
      Adds a bundle to the registry.
      Parameters:
      bundle - The bundle to register
      Returns:
      the bundle
      Throws:
      IllegalArgumentException - if any of the provided resources of the given bundle is already provided by a different bundle.
    • findBundle

      Finds a bundle that provides the given item.
      Parameters:
      item - The item that should be provided by the bundle.
      Returns:
      The bundle that provides the given item or null if no bundle is found.