use of org.apache.wicket.request.resource.JavaScriptResourceReference 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.JavaScriptResourceReference in project wicket by apache.
the class ResourceBundles method 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 {@link #addBundle(HeaderItem)} with a
* {@link JavaScriptHeaderItem} for a {@link ConcatResourceBundleReference}.
*
* @param scope
* The {@linkplain ResourceReference#getScope() scope} of the bundle
* @param defer
* specifies that the execution of a script should be deferred (delayed) until after
* the page has been loaded.
* @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 JavaScriptReferenceHeaderItem addJavaScriptBundle(Class<?> scope, String name, boolean defer, JavaScriptResourceReference... references) {
List<JavaScriptReferenceHeaderItem> items = new ArrayList<>();
for (JavaScriptResourceReference curReference : references) {
items.add(JavaScriptHeaderItem.forReference(curReference));
}
ConcatResourceBundleReference<JavaScriptReferenceHeaderItem> bundleReference = newBundleResourceReference(scope, name, items);
if (Application.exists()) {
IJavaScriptCompressor javaScriptCompressor = Application.get().getResourceSettings().getJavaScriptCompressor();
bundleReference.setCompressor(javaScriptCompressor);
}
if (defer) {
return addBundle(JavaScriptHeaderItem.forReference(bundleReference, defer));
} else {
return addBundle(JavaScriptHeaderItem.forReference(bundleReference));
}
}
use of org.apache.wicket.request.resource.JavaScriptResourceReference in project wicket by apache.
the class CompressBundlesTest method newApplication.
@Override
protected WebApplication newApplication() {
return new MockApplication() {
@Override
protected void init() {
super.init();
// remove that setting to see the original (non-compressed) version of the bundle
getResourceSettings().setJavaScriptCompressor(new DefaultJavaScriptCompressor());
getResourceBundles().addJavaScriptBundle(CompressBundlesTest.class, "bundle.js", new JavaScriptResourceReference(CompressBundlesTest.class, "two.js"), new JavaScriptResourceReference(CompressBundlesTest.class, "one.js"));
}
};
}
use of org.apache.wicket.request.resource.JavaScriptResourceReference in project openmeetings by apache.
the class ActivitiesPanel method renderHead.
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(ActivitiesPanel.class, "activities.js"))));
}
use of org.apache.wicket.request.resource.JavaScriptResourceReference in project openmeetings by apache.
the class PollResultsDialog method renderHead.
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
response.render(JavaScriptHeaderItem.forReference(JqPlotJavascriptResourceReference.get()));
response.render(CssHeaderItem.forReference(JqPlotCssResourceReference.get()));
Chart<?> c1 = new PieChart<>(null);
c1.getChartConfiguration().setHighlighter(new Highlighter());
for (Chart<?> chart : new Chart<?>[] { c1, new BarChart<Integer>(null) }) {
for (String resource : JqPlotUtils.retriveJavaScriptResources(chart)) {
response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(JqPlotBehavior.class, removeMinified(resource))));
}
}
}
Aggregations