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));
}
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);
}
};
}
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"));
});
}
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));
}
Aggregations