Search in sources :

Example 1 with JavaScriptResourceReference

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));
}
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 JavaScriptResourceReference

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));
    }
}
Also used : JavaScriptReferenceHeaderItem(org.apache.wicket.markup.head.JavaScriptReferenceHeaderItem) JavaScriptResourceReference(org.apache.wicket.request.resource.JavaScriptResourceReference) IJavaScriptCompressor(org.apache.wicket.javascript.IJavaScriptCompressor) ArrayList(java.util.ArrayList)

Example 3 with JavaScriptResourceReference

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"));
        }
    };
}
Also used : MockApplication(org.apache.wicket.mock.MockApplication) JavaScriptResourceReference(org.apache.wicket.request.resource.JavaScriptResourceReference) DefaultJavaScriptCompressor(org.apache.wicket.javascript.DefaultJavaScriptCompressor)

Example 4 with JavaScriptResourceReference

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"))));
}
Also used : PriorityHeaderItem(org.apache.wicket.markup.head.PriorityHeaderItem) JavaScriptResourceReference(org.apache.wicket.request.resource.JavaScriptResourceReference)

Example 5 with JavaScriptResourceReference

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))));
        }
    }
}
Also used : PieChart(br.com.digilabs.jqplot.chart.PieChart) JavaScriptResourceReference(org.apache.wicket.request.resource.JavaScriptResourceReference) BarChart(br.com.digilabs.jqplot.chart.BarChart) PieChart(br.com.digilabs.jqplot.chart.PieChart) BarChart(br.com.digilabs.jqplot.chart.BarChart) Chart(br.com.digilabs.jqplot.Chart) Highlighter(br.com.digilabs.jqplot.elements.Highlighter)

Aggregations

JavaScriptResourceReference (org.apache.wicket.request.resource.JavaScriptResourceReference)12 PriorityHeaderItem (org.apache.wicket.markup.head.PriorityHeaderItem)6 ArrayList (java.util.ArrayList)3 HeaderItem (org.apache.wicket.markup.head.HeaderItem)2 JavaScriptHeaderItem (org.apache.wicket.markup.head.JavaScriptHeaderItem)2 JQueryPluginResourceReference (org.apache.wicket.resource.JQueryPluginResourceReference)2 Chart (br.com.digilabs.jqplot.Chart)1 BarChart (br.com.digilabs.jqplot.chart.BarChart)1 PieChart (br.com.digilabs.jqplot.chart.PieChart)1 Highlighter (br.com.digilabs.jqplot.elements.Highlighter)1 ChatMessage (org.apache.openmeetings.db.entity.basic.ChatMessage)1 Room (org.apache.openmeetings.db.entity.room.Room)1 DefaultJavaScriptCompressor (org.apache.wicket.javascript.DefaultJavaScriptCompressor)1 IJavaScriptCompressor (org.apache.wicket.javascript.IJavaScriptCompressor)1 CssHeaderItem (org.apache.wicket.markup.head.CssHeaderItem)1 JavaScriptReferenceHeaderItem (org.apache.wicket.markup.head.JavaScriptReferenceHeaderItem)1 FilteredHeaderItem (org.apache.wicket.markup.head.filter.FilteredHeaderItem)1 MockApplication (org.apache.wicket.mock.MockApplication)1 CssResourceReference (org.apache.wicket.request.resource.CssResourceReference)1