org.apache.wicket
Class ResourceBundles

java.lang.Object
  extended by 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 Summary
ResourceBundles(ResourceReferenceRegistry registry)
          Construct.
 
Method Summary
<T extends HeaderItem>
T
addBundle(T bundle)
          Adds a bundle to the registry.
 CssReferenceHeaderItem addCssBundle(Class<?> scope, String name, CssResourceReference... references)
          Adds a css bundle that is automatically generated by concatenating the given package resources.
 JavaScriptReferenceHeaderItem addJavaScriptBundle(Class<?> scope, String name, JavaScriptResourceReference... references)
          Adds a javascript bundle that is automatically generated by concatenating the given package resources.
 HeaderItem findBundle(HeaderItem item)
          Finds a bundle that provides the given item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceBundles

public ResourceBundles(ResourceReferenceRegistry registry)
Construct.

Parameters:
registry - the registry that keeps all referenced resources
Method Detail

addJavaScriptBundle

public JavaScriptReferenceHeaderItem addJavaScriptBundle(Class<?> scope,
                                                         String name,
                                                         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
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

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

public HeaderItem findBundle(HeaderItem item)
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.


Copyright © 2006-2013 Apache Software Foundation. All Rights Reserved.