Search in sources :

Example 11 with HeaderItem

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

the class FilteredHeaderPage method renderHead.

@Override
public void renderHead(IHeaderResponse response) {
    // rendered at the default header bucket
    final JavaScriptResourceReference topJsReference = new JavaScriptResourceReference(FilteredHeaderPage.class, "top.js");
    response.render(new FilteredHeaderItem(JavaScriptHeaderItem.forReference(topJsReference), FilteringHeaderResponse.DEFAULT_HEADER_FILTER_NAME));
    // rendered at the bottom of the body bucket
    JQueryPluginResourceReference bottomJs = new JQueryPluginResourceReference(FilteredHeaderPage.class, "bottom.js") {

        private static final long serialVersionUID = 1L;

        @Override
        public List<HeaderItem> getDependencies() {
            List<HeaderItem> dependencies = super.getDependencies();
            // WICKET-4566 : depend on a resource which is rendered in a different bucket
            dependencies.add(JavaScriptHeaderItem.forReference(topJsReference));
            return dependencies;
        }
    };
    response.render(JavaScriptHeaderItem.forReference(bottomJs));
}
Also used : JQueryPluginResourceReference(org.apache.wicket.resource.JQueryPluginResourceReference) JavaScriptResourceReference(org.apache.wicket.request.resource.JavaScriptResourceReference) HeaderItem(org.apache.wicket.markup.head.HeaderItem) JavaScriptHeaderItem(org.apache.wicket.markup.head.JavaScriptHeaderItem)

Example 12 with HeaderItem

use of org.apache.wicket.markup.head.HeaderItem in project wiquery by WiQuery.

the class CoreUIJavaScriptResourceReference method getDependencies.

@Override
public List<HeaderItem> getDependencies() {
    Iterable<? extends HeaderItem> jquery = super.getDependencies();
    List<HeaderItem> ret = new ArrayList<HeaderItem>();
    for (HeaderItem curItem : jquery) ret.add(curItem);
    ret.add(CssHeaderItem.forReference(WiQueryCoreThemeResourceReference.get()));
    return ret;
}
Also used : ArrayList(java.util.ArrayList) HeaderItem(org.apache.wicket.markup.head.HeaderItem) CssHeaderItem(org.apache.wicket.markup.head.CssHeaderItem)

Example 13 with HeaderItem

use of org.apache.wicket.markup.head.HeaderItem in project hale by halestudio.

the class OpenIdSelectorJsReference method getDependencies.

@Override
public Iterable<? extends HeaderItem> getDependencies() {
    List<HeaderItem> deps = new ArrayList<HeaderItem>();
    for (HeaderItem dep : super.getDependencies()) {
        deps.add(dep);
    }
    deps.add(CssHeaderItem.forReference(OpenIdSelectorCssReference.INSTANCE));
    deps.add(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OpenIdSelectorJsReference.class, "js/openid-jquery.js")));
    return deps;
}
Also used : JavaScriptResourceReference(org.apache.wicket.request.resource.JavaScriptResourceReference) ArrayList(java.util.ArrayList) HeaderItem(org.apache.wicket.markup.head.HeaderItem) CssHeaderItem(org.apache.wicket.markup.head.CssHeaderItem) JavaScriptHeaderItem(org.apache.wicket.markup.head.JavaScriptHeaderItem)

Example 14 with HeaderItem

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

the class ResourceBundleReference method getDependencies.

@Override
public List<HeaderItem> getDependencies() {
    Set<HeaderItem> ret = new LinkedHashSet<>();
    for (HeaderItem curProvided : providedResources) {
        for (HeaderItem curDependency : curProvided.getDependencies()) ret.add(curDependency);
    }
    for (HeaderItem curProvided : providedResources) {
        ret.remove(curProvided);
    }
    List<HeaderItem> dependencies = super.getDependencies();
    dependencies.addAll(ret);
    return dependencies;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) HeaderItem(org.apache.wicket.markup.head.HeaderItem)

Example 15 with HeaderItem

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

the class FilteringHeaderResponse method getContent.

/**
 * Gets the content that was rendered to this header response and matched the filter with the
 * given name.
 *
 * @param filterName
 *            the name of the filter to get the bucket for
 * @return the content that was accepted by the filter with this name
 */
@SuppressWarnings("resource")
public final CharSequence getContent(String filterName) {
    if (filterName == null || !responseFilterMap.containsKey(filterName)) {
        return "";
    }
    List<HeaderItem> resp = responseFilterMap.get(filterName);
    final StringResponse strResponse = new StringResponse();
    IHeaderResponse headerRenderer = new HeaderResponse() {

        @Override
        protected Response getRealResponse() {
            return strResponse;
        }

        @Override
        public boolean wasRendered(Object object) {
            return FilteringHeaderResponse.this.getRealResponse().wasRendered(object);
        }

        @Override
        public void markRendered(Object object) {
            FilteringHeaderResponse.this.getRealResponse().markRendered(object);
        }
    };
    headerRenderer = decorate(headerRenderer);
    for (HeaderItem curItem : resp) {
        headerRenderer.render(curItem);
    }
    headerRenderer.close();
    return strResponse.getBuffer();
}
Also used : HeaderResponse(org.apache.wicket.markup.head.internal.HeaderResponse) IHeaderResponse(org.apache.wicket.markup.head.IHeaderResponse) DecoratingHeaderResponse(org.apache.wicket.markup.html.DecoratingHeaderResponse) IHeaderResponse(org.apache.wicket.markup.head.IHeaderResponse) HeaderItem(org.apache.wicket.markup.head.HeaderItem) StringResponse(org.apache.wicket.response.StringResponse)

Aggregations

HeaderItem (org.apache.wicket.markup.head.HeaderItem)22 PriorityHeaderItem (org.apache.wicket.markup.head.PriorityHeaderItem)10 Test (org.junit.Test)10 JavaScriptHeaderItem (org.apache.wicket.markup.head.JavaScriptHeaderItem)7 JavaScriptResourceReference (org.apache.wicket.request.resource.JavaScriptResourceReference)6 ResourceReference (org.apache.wicket.request.resource.ResourceReference)5 ArrayList (java.util.ArrayList)4 LinkedHashSet (java.util.LinkedHashSet)2 CssHeaderItem (org.apache.wicket.markup.head.CssHeaderItem)2 IHeaderResponse (org.apache.wicket.markup.head.IHeaderResponse)2 WicketAjaxJQueryResourceReference (org.apache.wicket.ajax.WicketAjaxJQueryResourceReference)1 IReferenceHeaderItem (org.apache.wicket.markup.head.IReferenceHeaderItem)1 IWrappedHeaderItem (org.apache.wicket.markup.head.IWrappedHeaderItem)1 JavaScriptReferenceHeaderItem (org.apache.wicket.markup.head.JavaScriptReferenceHeaderItem)1 ResourceAggregator (org.apache.wicket.markup.head.ResourceAggregator)1 HeaderResponse (org.apache.wicket.markup.head.internal.HeaderResponse)1 DecoratingHeaderResponse (org.apache.wicket.markup.html.DecoratingHeaderResponse)1 XmlPullParser (org.apache.wicket.markup.parser.XmlPullParser)1 XmlTag (org.apache.wicket.markup.parser.XmlTag)1 PackageResourceReference (org.apache.wicket.request.resource.PackageResourceReference)1