Package org.apache.wicket.markup.head
Class CssHeaderItem
- java.lang.Object
-
- org.apache.wicket.markup.head.HeaderItem
-
- org.apache.wicket.markup.head.CssHeaderItem
-
- All Implemented Interfaces:
java.io.Serializable
,org.apache.wicket.util.io.IClusterable
- Direct Known Subclasses:
CssContentHeaderItem
,CssReferenceHeaderItem
,CssUrlReferenceHeaderItem
public abstract class CssHeaderItem extends HeaderItem
Base class for allHeaderItem
s that represent stylesheets. This class mainly contains factory methods.- Author:
- papegaaij
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CssHeaderItem(java.lang.String condition)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
static CssContentHeaderItem
forCSS(java.lang.CharSequence css, java.lang.String id)
Creates aCssContentHeaderItem
for the given content.static CssContentHeaderItem
forCSS(java.lang.CharSequence css, java.lang.String id, java.lang.String condition)
Creates aCssContentHeaderItem
for the given content.static CssReferenceHeaderItem
forReference(ResourceReference reference)
Creates aCssReferenceHeaderItem
for the given reference.static CssReferenceHeaderItem
forReference(ResourceReference reference, java.lang.String media)
Creates aCssReferenceHeaderItem
for the given reference.static CssReferenceHeaderItem
forReference(ResourceReference reference, org.apache.wicket.request.mapper.parameter.PageParameters pageParameters, java.lang.String media)
Creates aCssReferenceHeaderItem
for the given reference.static CssReferenceHeaderItem
forReference(ResourceReference reference, org.apache.wicket.request.mapper.parameter.PageParameters pageParameters, java.lang.String media, java.lang.String condition)
Creates aCssReferenceHeaderItem
for the given reference.static CssReferenceHeaderItem
forReference(ResourceReference reference, org.apache.wicket.request.mapper.parameter.PageParameters pageParameters, java.lang.String media, java.lang.String condition, java.lang.String rel)
Creates aCssReferenceHeaderItem
for the given reference.static CssUrlReferenceHeaderItem
forUrl(java.lang.String url)
Creates aCssUrlReferenceHeaderItem
for the given url.static CssUrlReferenceHeaderItem
forUrl(java.lang.String url, java.lang.String media)
Creates aCssUrlReferenceHeaderItem
for the given url.static CssUrlReferenceHeaderItem
forUrl(java.lang.String url, java.lang.String media, java.lang.String condition)
Creates aCssUrlReferenceHeaderItem
for the given url.static CssUrlReferenceHeaderItem
forUrl(java.lang.String url, java.lang.String media, java.lang.String condition, java.lang.String rel)
Creates aCssUrlReferenceHeaderItem
for the given url.java.lang.String
getCondition()
java.lang.String
getId()
int
hashCode()
protected void
internalRenderCSSReference(org.apache.wicket.request.Response response, java.lang.String url, java.lang.String media, java.lang.String condition, java.lang.String rel)
CssHeaderItem
setId(java.lang.String markupId)
-
Methods inherited from class org.apache.wicket.markup.head.HeaderItem
getDependencies, getProvidedResources, getRenderTokens, render
-
-
-
-
Method Detail
-
getId
public java.lang.String getId()
- Returns:
- an optional markup id for the <link> HTML element that will be rendered for this header item
-
setId
public CssHeaderItem setId(java.lang.String markupId)
- Parameters:
markupId
- an optional markup id for this header item- Returns:
this
object, for method chaining
-
getCondition
public java.lang.String getCondition()
- Returns:
- the condition to use for Internet Explorer conditional comments. E.g. "IE 7".
-
forReference
public static CssReferenceHeaderItem forReference(ResourceReference reference)
Creates aCssReferenceHeaderItem
for the given reference.- Parameters:
reference
- a reference to a CSS resource- Returns:
- A newly created
CssReferenceHeaderItem
for the given reference.
-
forReference
public static CssReferenceHeaderItem forReference(ResourceReference reference, java.lang.String media)
Creates aCssReferenceHeaderItem
for the given reference.- Parameters:
reference
- a reference to a CSS resourcemedia
- the media type for this CSS ("print", "screen", etc.)- Returns:
- A newly created
CssReferenceHeaderItem
for the given reference.
-
forReference
public static CssReferenceHeaderItem forReference(ResourceReference reference, org.apache.wicket.request.mapper.parameter.PageParameters pageParameters, java.lang.String media)
Creates aCssReferenceHeaderItem
for the given reference.- Parameters:
reference
- a reference to a CSS resourcepageParameters
- the parameters for this CSS resource referencemedia
- the media type for this CSS ("print", "screen", etc.)- Returns:
- A newly created
CssReferenceHeaderItem
for the given reference.
-
forReference
public static CssReferenceHeaderItem forReference(ResourceReference reference, org.apache.wicket.request.mapper.parameter.PageParameters pageParameters, java.lang.String media, java.lang.String condition)
Creates aCssReferenceHeaderItem
for the given reference. Warning: the conditional comments don't work when injected dynamically with JavaScript (i.e. in Ajax response). An alternative solution is to use user agent sniffing at the server side: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" )); } }
- Parameters:
reference
- a reference to a 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".- Returns:
- A newly created
CssReferenceHeaderItem
for the given reference.
-
forReference
public static CssReferenceHeaderItem forReference(ResourceReference reference, org.apache.wicket.request.mapper.parameter.PageParameters pageParameters, java.lang.String media, java.lang.String condition, java.lang.String rel)
Creates aCssReferenceHeaderItem
for the given reference. Warning: the conditional comments don't work when injected dynamically with JavaScript (i.e. in Ajax response). An alternative solution is to use user agent sniffing at the server side: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" )); } }
- Parameters:
reference
- a reference to a 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".rel
- the rel attribute content- Returns:
- A newly created
CssReferenceHeaderItem
for the given reference.
-
forCSS
public static CssContentHeaderItem forCSS(java.lang.CharSequence css, java.lang.String id)
Creates aCssContentHeaderItem
for the given content.- Parameters:
css
- css content to be rendered.id
- unique id for the <style> element. This can benull
, however in that case the ajax header contribution can't detect duplicate CSS fragments.- Returns:
- A newly created
CssContentHeaderItem
for the given content.
-
forCSS
public static CssContentHeaderItem forCSS(java.lang.CharSequence css, java.lang.String id, java.lang.String condition)
Creates aCssContentHeaderItem
for the given content. Warning: the conditional comments don't work when injected dynamically with JavaScript (i.e. in Ajax response). An alternative solution is to use user agent sniffing at the server side: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" )); } }
- Parameters:
css
- css content to be rendered.id
- unique id for the <style> element. This can benull
, however in that case the ajax header contribution can't detect duplicate CSS fragments.condition
- the condition to use for Internet Explorer conditional comments. E.g. "IE 7".- Returns:
- A newly created
CssContentHeaderItem
for the given content.
-
forUrl
public static CssUrlReferenceHeaderItem forUrl(java.lang.String url)
Creates aCssUrlReferenceHeaderItem
for the given url.- Parameters:
url
- context-relative url of the CSS resource- Returns:
- A newly created
CssUrlReferenceHeaderItem
for the given url.
-
forUrl
public static CssUrlReferenceHeaderItem forUrl(java.lang.String url, java.lang.String media)
Creates aCssUrlReferenceHeaderItem
for the given url.- Parameters:
url
- context-relative url of the CSS resourcemedia
- the media type for this CSS ("print", "screen", etc.)- Returns:
- A newly created
CssUrlReferenceHeaderItem
for the given url.
-
forUrl
public static CssUrlReferenceHeaderItem forUrl(java.lang.String url, java.lang.String media, java.lang.String condition)
Creates aCssUrlReferenceHeaderItem
for the given url. Warning: the conditional comments don't work when injected dynamically with JavaScript (i.e. in Ajax response). An alternative solution is to use user agent sniffing at the server side: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" )); } }
- Parameters:
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".- Returns:
- A newly created
CssUrlReferenceHeaderItem
for the given url.
-
forUrl
public static CssUrlReferenceHeaderItem forUrl(java.lang.String url, java.lang.String media, java.lang.String condition, java.lang.String rel)
Creates aCssUrlReferenceHeaderItem
for the given url. Warning: the conditional comments don't work when injected dynamically with JavaScript (i.e. in Ajax response). An alternative solution is to use user agent sniffing at the server side: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" )); } }
- Parameters:
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".rel
- the rel attribute content- Returns:
- A newly created
CssUrlReferenceHeaderItem
for the given url.
-
internalRenderCSSReference
protected final void internalRenderCSSReference(org.apache.wicket.request.Response response, java.lang.String url, java.lang.String media, java.lang.String condition, java.lang.String rel)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-