java.lang.Object
org.apache.wicket.markup.head.HeaderItem
org.apache.wicket.markup.head.AbstractCspHeaderItem
org.apache.wicket.markup.head.CssHeaderItem
- All Implemented Interfaces:
Serializable
,IClusterable
- Direct Known Subclasses:
AbstractCssReferenceHeaderItem
,CssContentHeaderItem
Base class for all
HeaderItem
s that represent stylesheets. This class mainly contains
factory methods.- Author:
- papegaaij
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
static CssContentHeaderItem
forCSS
(CharSequence css, String id) Creates aCssContentHeaderItem
for the given content.static CssReferenceHeaderItem
forReference
(ResourceReference reference) Creates aCssReferenceHeaderItem
for the given reference.static CssReferenceHeaderItem
forReference
(ResourceReference reference, String media) Creates aCssReferenceHeaderItem
for the given reference.static CssReferenceHeaderItem
forReference
(ResourceReference reference, PageParameters pageParameters, String media) Creates aCssReferenceHeaderItem
for the given reference.static CssReferenceHeaderItem
forReference
(ResourceReference reference, PageParameters pageParameters, String media, String rel) Creates aCssReferenceHeaderItem
for the given reference.static CssUrlReferenceHeaderItem
Creates aCssUrlReferenceHeaderItem
for the given url.static CssUrlReferenceHeaderItem
Creates aCssUrlReferenceHeaderItem
for the given url.static CssUrlReferenceHeaderItem
Creates aCssUrlReferenceHeaderItem
for the given url.getId()
int
hashCode()
Methods inherited from class org.apache.wicket.markup.head.AbstractCspHeaderItem
getNonce, setNonce
Methods inherited from class org.apache.wicket.markup.head.HeaderItem
getDependencies, getProvidedResources, getRenderTokens, render
-
Constructor Details
-
CssHeaderItem
public CssHeaderItem()
-
-
Method Details
-
getId
- Returns:
- an optional markup id for the <link> HTML element that will be rendered for this header item
-
setId
- Parameters:
markupId
- an optional markup id for this header item- Returns:
this
object, for method chaining
-
forReference
Creates aCssReferenceHeaderItem
for the given reference.- Parameters:
reference
- a reference to a CSS resource- Returns:
- A newly created
CssReferenceHeaderItem
for the given reference.
-
forReference
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, PageParameters pageParameters, 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, PageParameters pageParameters, String media, 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.)rel
- the rel attribute content- Returns:
- A newly created
CssReferenceHeaderItem
for the given reference.
-
forCSS
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.
-
forUrl
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
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
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.)rel
- the rel attribute content- Returns:
- A newly created
CssUrlReferenceHeaderItem
for the given url.
-
equals
-
hashCode
-