Search in sources :

Example 1 with CssReferenceHeaderItem

use of org.apache.wicket.markup.head.CssReferenceHeaderItem in project wicket by apache.

the class ResourceBundles method addCssBundle.

/**
 * 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 {@link #addBundle(HeaderItem)} with a {@link CssHeaderItem} for
 * a {@link ConcatResourceBundleReference}.
 *
 * @param scope
 *            The {@linkplain ResourceReference#getScope() scope} of the bundle
 * @param name
 *            The name of the resource. This will show up as the filename in the markup.
 * @param references
 *            The resources this bundle will consist of.
 * @return the newly created bundle
 */
public CssReferenceHeaderItem addCssBundle(Class<?> scope, String name, CssResourceReference... references) {
    List<CssReferenceHeaderItem> items = new ArrayList<CssReferenceHeaderItem>();
    for (CssResourceReference curReference : references) {
        items.add(CssHeaderItem.forReference(curReference));
    }
    ConcatResourceBundleReference<CssReferenceHeaderItem> bundleReference = newBundleResourceReference(scope, name, items);
    if (Application.exists()) {
        ICssCompressor cssCompressor = Application.get().getResourceSettings().getCssCompressor();
        bundleReference.setCompressor(cssCompressor);
    }
    return addBundle(CssHeaderItem.forReference(bundleReference));
}
Also used : ICssCompressor(org.apache.wicket.css.ICssCompressor) ArrayList(java.util.ArrayList) CssReferenceHeaderItem(org.apache.wicket.markup.head.CssReferenceHeaderItem) CssResourceReference(org.apache.wicket.request.resource.CssResourceReference)

Aggregations

ArrayList (java.util.ArrayList)1 ICssCompressor (org.apache.wicket.css.ICssCompressor)1 CssReferenceHeaderItem (org.apache.wicket.markup.head.CssReferenceHeaderItem)1 CssResourceReference (org.apache.wicket.request.resource.CssResourceReference)1