|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.markup.html.DecoratingHeaderResponse org.apache.wicket.resource.filtering.HeaderResponseContainerFilteringHeaderResponse
public class HeaderResponseContainerFilteringHeaderResponse
This header response allows you to separate things that are added to the IHeaderResponse into different buckets. Then, you can render those different buckets in separate areas of the page based on your filter logic. A typical use case for this header response is to move the loading of JavaScript files (and inline script tags) to the footer of the page.
HeaderResponseFilteredResponseContainer
,
CssAcceptingHeaderResponseFilter
,
JavaScriptAcceptingHeaderResponseFilter
Nested Class Summary | |
---|---|
static interface |
HeaderResponseContainerFilteringHeaderResponse.IHeaderResponseFilter
A filter used to bucket your resources, inline scripts, etc, into different responses. |
Constructor Summary | |
---|---|
HeaderResponseContainerFilteringHeaderResponse(IHeaderResponse response,
String headerFilterName,
HeaderResponseContainerFilteringHeaderResponse.IHeaderResponseFilter[] filters)
Construct. |
Method Summary | |
---|---|
void |
close()
Mark Header rendering is completed and subsequent usage will be ignored. |
static HeaderResponseContainerFilteringHeaderResponse |
get()
|
CharSequence |
getContent(String filterName)
Gets the content that was rendered to this header response and matched the filter with the given name. |
void |
renderCSS(CharSequence css,
String id)
Renders CSS code to the response, if the CSS has not already been rendered. |
void |
renderCSSReference(ResourceReference reference)
Writes a CSS reference, if the specified reference hasn't been rendered yet. |
void |
renderCSSReference(ResourceReference reference,
PageParameters pageParameters,
String media)
Writes a CSS reference with query parameters, if the specified reference hasn't been rendered yet. |
void |
renderCSSReference(ResourceReference reference,
PageParameters pageParameters,
String media,
String condition)
Writes a conditional IE comment with a CSS reference with query parameters, if the specified reference hasn't been rendered yet. |
void |
renderCSSReference(ResourceReference reference,
String media)
Writes a CSS reference, if the specified reference hasn't been rendered yet. |
void |
renderCSSReference(String url)
Writes a CSS reference, if the specified reference hasn't been rendered yet. |
void |
renderCSSReference(String url,
String media)
Writes a link to a CSS resource, if the specified url hasn't been rendered yet. |
void |
renderCSSReference(String url,
String media,
String condition)
Writes a conditional IE comment for a link to a CSS resource, if the specified url hasn't been rendered yet. |
void |
renderJavaScript(CharSequence javascript,
String id)
Renders javascript code to the response, if the javascript has not already been rendered. |
void |
renderJavaScriptReference(ResourceReference reference)
Writes a javascript reference, if the specified reference hasn't been rendered yet. |
void |
renderJavaScriptReference(ResourceReference reference,
PageParameters pageParameters,
String id)
Writes a javascript reference with query parameters, if the specified reference hasn't been rendered yet. |
void |
renderJavaScriptReference(ResourceReference reference,
PageParameters pageParameters,
String id,
boolean defer)
Writes a javascript reference with query parameters, if the specified reference hasn't been rendered yet. |
void |
renderJavaScriptReference(ResourceReference reference,
PageParameters pageParameters,
String id,
boolean defer,
String charset)
Writes a javascript reference with query parameters, if the specified reference hasn't been rendered yet. |
void |
renderJavaScriptReference(ResourceReference reference,
String id)
Writes a javascript reference, if the specified reference hasn't been rendered yet. |
void |
renderJavaScriptReference(String url)
Writes a javascript reference, if the specified reference hasn't been rendered yet. |
void |
renderJavaScriptReference(String url,
String id)
Writes a javascript reference, if the specified reference hasn't been rendered yet. |
void |
renderJavaScriptReference(String url,
String id,
boolean defer)
Writes a javascript reference, if the specified reference hasn't been rendered yet. |
void |
renderJavaScriptReference(String url,
String id,
boolean defer,
String charset)
Writes a javascript reference, if the specified reference hasn't been rendered yet. |
void |
renderOnDomReadyJavaScript(String javascript)
Renders javascript that is executed right after the DOM is built, before external resources (e.g. images) are loaded. |
void |
renderOnEventJavaScript(String target,
String event,
String javascript)
Renders javascript that is executed after the given event happens on specified target |
void |
renderOnLoadJavaScript(String javascript)
Renders javascript that is executed after the entire page is loaded. |
protected void |
runWithFilter(Runnable runnable,
String filterName)
If subclasses of this class have special cases where they force something into a particular bucket, regardless of the filters, they can create a Runnable that renders to the real response, and pass it to this method with the name of the filter (bucket) that they want it to appear in. |
protected void |
setFilters(HeaderResponseContainerFilteringHeaderResponse.IHeaderResponseFilter[] filters)
|
Methods inherited from class org.apache.wicket.markup.html.DecoratingHeaderResponse |
---|
getRealResponse, getResponse, isClosed, markRendered, renderString, wasRendered |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HeaderResponseContainerFilteringHeaderResponse(IHeaderResponse response, String headerFilterName, HeaderResponseContainerFilteringHeaderResponse.IHeaderResponseFilter[] filters)
response
- the wrapped IHeaderResponseheaderFilterName
- the name that the filter for things that should appear in the head (default Wicket
location) usesfilters
- the filters to use to bucket things. There will be a bucket created for each
filter, by name. There should typically be at least one filter with the same name
as your headerFilterNameMethod Detail |
---|
protected void setFilters(HeaderResponseContainerFilteringHeaderResponse.IHeaderResponseFilter[] filters)
public static HeaderResponseContainerFilteringHeaderResponse get()
public void renderJavaScriptReference(ResourceReference reference)
IHeaderResponse
renderJavaScriptReference
in interface IHeaderResponse
renderJavaScriptReference
in class DecoratingHeaderResponse
reference
- resource reference pointing to the javascript resourcepublic void renderJavaScriptReference(ResourceReference reference, String id)
IHeaderResponse
renderJavaScriptReference
in interface IHeaderResponse
renderJavaScriptReference
in class DecoratingHeaderResponse
reference
- resource reference pointing to the javascript resourceid
- id that will be used to filter duplicate reference (it's still filtered by URL
too)public void renderJavaScriptReference(ResourceReference reference, PageParameters pageParameters, String id)
IHeaderResponse
renderJavaScriptReference
in interface IHeaderResponse
renderJavaScriptReference
in class DecoratingHeaderResponse
reference
- resource reference pointing to the javascript resourcepageParameters
- the parameters for this Javascript resource referenceid
- id that will be used to filter duplicate reference (it's still filtered by URL
too)public void renderJavaScriptReference(String url)
IHeaderResponse
renderJavaScriptReference
in interface IHeaderResponse
renderJavaScriptReference
in class DecoratingHeaderResponse
url
- context-relative url of the the javascript resourcepublic void renderJavaScriptReference(String url, String id)
IHeaderResponse
renderJavaScriptReference
in interface IHeaderResponse
renderJavaScriptReference
in class DecoratingHeaderResponse
url
- context-relative url of the the javascript resourceid
- id that will be used to filter duplicate reference (it's still filtered by URL
too)public void renderJavaScriptReference(String url, String id, boolean defer)
IHeaderResponse
renderJavaScriptReference
in interface IHeaderResponse
renderJavaScriptReference
in class DecoratingHeaderResponse
url
- context-relative url of the the javascript resourceid
- id that will be used to filter duplicate reference (it's still filtered by URL
too)defer
- specifies that the execution of a script should be deferred (delayed) until after
the page has been loaded.public void renderJavaScriptReference(String url, String id, boolean defer, String charset)
IHeaderResponse
renderJavaScriptReference
in interface IHeaderResponse
renderJavaScriptReference
in class DecoratingHeaderResponse
url
- context-relative url of the the javascript resourceid
- id that will be used to filter duplicate reference (it's still filtered by URL
too)defer
- specifies that the execution of a script should be deferred (delayed) until after
the page has been loaded.charset
- a non null value specifies the charset attribute of the script tagpublic void renderJavaScript(CharSequence javascript, String id)
IHeaderResponse
script
tags will be added to the output.
renderJavaScript
in interface IHeaderResponse
renderJavaScript
in class DecoratingHeaderResponse
javascript
- javascript content to be rendered.id
- unique id for the javascript element. This can be null, however in that case the
ajax header contribution can't detect duplicate script fragments.public void renderCSSReference(ResourceReference reference)
IHeaderResponse
renderCSSReference
in interface IHeaderResponse
renderCSSReference
in class DecoratingHeaderResponse
reference
- resource reference pointing to the CSS resourcepublic void renderCSSReference(String url)
IHeaderResponse
renderCSSReference
in interface IHeaderResponse
renderCSSReference
in class DecoratingHeaderResponse
url
- context-relative url of the CSS resourcepublic void renderCSSReference(ResourceReference reference, String media)
IHeaderResponse
renderCSSReference
in interface IHeaderResponse
renderCSSReference
in class DecoratingHeaderResponse
reference
- resource reference pointing to the CSS resourcemedia
- the media type for this CSS ("print", "screen", etc.)public void renderCSSReference(ResourceReference reference, PageParameters pageParameters, String media)
IHeaderResponse
renderCSSReference
in interface IHeaderResponse
renderCSSReference
in class DecoratingHeaderResponse
reference
- resource reference pointing to the CSS resourcepageParameters
- the parameters for this CSS resource referencemedia
- the media type for this CSS ("print", "screen", etc.)public void renderCSSReference(String url, String media)
IHeaderResponse
renderCSSReference
in interface IHeaderResponse
renderCSSReference
in class DecoratingHeaderResponse
url
- context-relative url of the CSS resourcemedia
- the media type for this CSS ("print", "screen", etc.)public void renderOnDomReadyJavaScript(String javascript)
IHeaderResponse
renderOnDomReadyJavaScript
in interface IHeaderResponse
renderOnDomReadyJavaScript
in class DecoratingHeaderResponse
public void renderOnLoadJavaScript(String javascript)
IHeaderResponse
renderOnLoadJavaScript
in interface IHeaderResponse
renderOnLoadJavaScript
in class DecoratingHeaderResponse
public void renderOnEventJavaScript(String target, String event, String javascript)
IHeaderResponse
renderOnEventJavaScript
in interface IHeaderResponse
renderOnEventJavaScript
in class DecoratingHeaderResponse
public void renderJavaScriptReference(ResourceReference reference, PageParameters pageParameters, String id, boolean defer)
IHeaderResponse
renderJavaScriptReference
in interface IHeaderResponse
renderJavaScriptReference
in class DecoratingHeaderResponse
reference
- resource reference pointing to the javascript resourcepageParameters
- the parameters for this Javascript resource referenceid
- id that will be used to filter duplicate reference (it's still filtered by URL
too)defer
- specifies that the execution of a script should be deferred (delayed) until after
the page has been loaded.public void renderJavaScriptReference(ResourceReference reference, PageParameters pageParameters, String id, boolean defer, String charset)
IHeaderResponse
renderJavaScriptReference
in interface IHeaderResponse
renderJavaScriptReference
in class DecoratingHeaderResponse
reference
- resource reference pointing to the javascript resourcepageParameters
- the parameters for this Javascript resource referenceid
- id that will be used to filter duplicate reference (it's still filtered by URL
too)defer
- specifies that the execution of a script should be deferred (delayed) until after
the page has been loaded.charset
- a non null value specifies the charset attribute of the script tagpublic void renderCSS(CharSequence css, String id)
IHeaderResponse
renderCSS
in interface IHeaderResponse
renderCSS
in class DecoratingHeaderResponse
css
- css content to be rendered.id
- unique id for the <style> element. This can be null
, however in
that case the ajax header contribution can't detect duplicate CSS fragments.public void renderCSSReference(ResourceReference reference, PageParameters pageParameters, String media, String condition)
IHeaderResponse
public void renderHead(IHeaderResponse response) {
WebClientInfo clientInfo = (WebClientInfo) getSession().getClientInfo();
ClientProperties properties = clientInfo.getProperties();
if (properties.isBrowserInternetExplorer() && properties.getBrowserVersionMajor() >= 8) {
response.renderCSSReference(new PackageResourceReference(MyPage.class, "my-conditional.css" ));
}
}
renderCSSReference
in interface IHeaderResponse
renderCSSReference
in class DecoratingHeaderResponse
reference
- resource reference pointing to the CSS resourcepageParameters
- the parameters for this CSS resource referencemedia
- the media type for this CSS ("print", "screen", etc.)condition
- the condition to use for Internet Explorer conditional comments. E.g. "IE 7".public void renderCSSReference(String url, String media, String condition)
IHeaderResponse
public void renderHead(IHeaderResponse response) {
WebClientInfo clientInfo = (WebClientInfo) getSession().getClientInfo();
ClientProperties properties = clientInfo.getProperties();
if (properties.isBrowserInternetExplorer() && properties.getBrowserVersionMajor() >= 8) {
response.renderCSSReference(new PackageResourceReference(MyPage.class, "my-conditional.css" ));
}
}
renderCSSReference
in interface IHeaderResponse
renderCSSReference
in class DecoratingHeaderResponse
url
- context-relative url of the CSS resourcemedia
- the media type for this CSS ("print", "screen", etc.)condition
- the condition to use for Internet Explorer conditional comments. E.g. "IE 7".public void close()
IHeaderResponse
close
in interface Closeable
close
in interface IHeaderResponse
close
in class DecoratingHeaderResponse
public final CharSequence getContent(String filterName)
filterName
- the name of the filter to get the bucket for
protected final void runWithFilter(Runnable runnable, String filterName)
public void renderJavascriptIntoHead(final String js, final String id) {
runWithFilter(new Runnable() {
public void run()
{
getRealResponse().renderJavascript(js, id);
}
}, "headerBucket");
}
runnable
- the runnable that renders to the real response.filterName
- the name of the filter bucket that you want the runnable to render into
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |