Search in sources :

Example 1 with CssResourceReference

use of org.apache.wicket.request.resource.CssResourceReference in project wicket by apache.

the class HomePage method renderHead.

@Override
public void renderHead(IHeaderResponse response) {
    super.renderHead(response);
    // example of things that may be shared for all your applications across your company,
    // two CSS resources in the same group. header.css is rendered first because has lower
    // "order" number
    response.render(CssHeaderItem.forReference(new CssResourceReference(HomePage.class, "footer.css")));
    response.render(CssHeaderItem.forReference(new CssResourceReference(HomePage.class, "header.css")));
    // example of something that may be in this single application:
    response.render(CssHeaderItem.forReference(new CssResourceReference(HomePage.class, "app.css")));
    // example of something that may be limited to certain pages:
    response.render(CssHeaderItem.forReference(new CssResourceReference(HomePage.class, "HomePage.css")));
    response.render(JavaScriptHeaderItem.forReference(new JQueryPluginResourceReference(HomePage.class, "HomePage.js")));
    response.render(new FilteredHeaderItem(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(HomePage.class, "top.js")), FilteringHeaderResponse.DEFAULT_HEADER_FILTER_NAME));
}
Also used : JQueryPluginResourceReference(org.apache.wicket.resource.JQueryPluginResourceReference) FilteredHeaderItem(org.apache.wicket.markup.head.filter.FilteredHeaderItem) JavaScriptResourceReference(org.apache.wicket.request.resource.JavaScriptResourceReference) CssResourceReference(org.apache.wicket.request.resource.CssResourceReference)

Example 2 with CssResourceReference

use of org.apache.wicket.request.resource.CssResourceReference in project wicket by apache.

the class ResourceMapperWithDecoratedResourcesTest method newApplication.

@Override
protected WebApplication newApplication() {
    return new MockApplication() {

        @Override
        public void init() {
            super.init();
            getResourceSettings().setCachingStrategy(new FilenameWithVersionResourceCachingStrategy(new CachingResourceVersion(new MessageDigestResourceVersion())));
            mountResource("stylesheet.css", new CssResourceReference(ResourceMapperWithDecoratedResourcesTest.class, "decorated-resource.css"));
            mountPage("/", HomePage.class);
        }
    };
}
Also used : FilenameWithVersionResourceCachingStrategy(org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy) MockApplication(org.apache.wicket.mock.MockApplication) CachingResourceVersion(org.apache.wicket.request.resource.caching.version.CachingResourceVersion) MessageDigestResourceVersion(org.apache.wicket.request.resource.caching.version.MessageDigestResourceVersion) CssResourceReference(org.apache.wicket.request.resource.CssResourceReference)

Example 3 with CssResourceReference

use of org.apache.wicket.request.resource.CssResourceReference in project wicket by apache.

the class ResourceDecorationApplication method init.

@Override
protected void init() {
    super.init();
    getResourceBundles().addCssBundle(ResourceDecorationApplication.class, "css-bundle.css", new CssResourceReference(HomePage.class, "footer.css"), new CssResourceReference(HomePage.class, "header.css"));
    setHeaderResponseDecorator(response -> {
        // footer (after </body>)
        return new ResourceAggregator(new JavaScriptFilteredIntoFooterHeaderResponse(response, "footerJS"));
    });
}
Also used : JavaScriptFilteredIntoFooterHeaderResponse(org.apache.wicket.markup.head.filter.JavaScriptFilteredIntoFooterHeaderResponse) ResourceAggregator(org.apache.wicket.markup.head.ResourceAggregator) CssResourceReference(org.apache.wicket.request.resource.CssResourceReference)

Example 4 with CssResourceReference

use of org.apache.wicket.request.resource.CssResourceReference 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

CssResourceReference (org.apache.wicket.request.resource.CssResourceReference)4 ArrayList (java.util.ArrayList)1 ICssCompressor (org.apache.wicket.css.ICssCompressor)1 CssReferenceHeaderItem (org.apache.wicket.markup.head.CssReferenceHeaderItem)1 ResourceAggregator (org.apache.wicket.markup.head.ResourceAggregator)1 FilteredHeaderItem (org.apache.wicket.markup.head.filter.FilteredHeaderItem)1 JavaScriptFilteredIntoFooterHeaderResponse (org.apache.wicket.markup.head.filter.JavaScriptFilteredIntoFooterHeaderResponse)1 MockApplication (org.apache.wicket.mock.MockApplication)1 JavaScriptResourceReference (org.apache.wicket.request.resource.JavaScriptResourceReference)1 FilenameWithVersionResourceCachingStrategy (org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy)1 CachingResourceVersion (org.apache.wicket.request.resource.caching.version.CachingResourceVersion)1 MessageDigestResourceVersion (org.apache.wicket.request.resource.caching.version.MessageDigestResourceVersion)1 JQueryPluginResourceReference (org.apache.wicket.resource.JQueryPluginResourceReference)1