org.apache.wicket.markup.head
Class CssHeaderItem

java.lang.Object
  extended by org.apache.wicket.markup.head.HeaderItem
      extended by org.apache.wicket.markup.head.CssHeaderItem
All Implemented Interfaces:
Serializable, IClusterable
Direct Known Subclasses:
CssContentHeaderItem, CssReferenceHeaderItem, CssUrlReferenceHeaderItem

public abstract class CssHeaderItem
extends HeaderItem

Base class for all HeaderItems that represent stylesheets. This class mainly contains factory methods.

Author:
papegaaij
See Also:
Serialized Form

Constructor Summary
protected CssHeaderItem(String condition)
           
 
Method Summary
static CssContentHeaderItem forCSS(CharSequence css, String id)
          Creates a CssContentHeaderItem for the given content.
static CssContentHeaderItem forCSS(CharSequence css, String id, String condition)
          Creates a CssContentHeaderItem for the given content.
static CssReferenceHeaderItem forReference(ResourceReference reference)
          Creates a CssReferenceHeaderItem for the given reference.
static CssReferenceHeaderItem forReference(ResourceReference reference, PageParameters pageParameters, String media)
          Creates a CssReferenceHeaderItem for the given reference.
static CssReferenceHeaderItem forReference(ResourceReference reference, PageParameters pageParameters, String media, String condition)
          Creates a CssReferenceHeaderItem for the given reference.
static CssReferenceHeaderItem forReference(ResourceReference reference, String media)
          Creates a CssReferenceHeaderItem for the given reference.
static CssUrlReferenceHeaderItem forUrl(String url)
          Creates a CssUrlReferenceHeaderItem for the given url.
static CssUrlReferenceHeaderItem forUrl(String url, String media)
          Creates a CssUrlReferenceHeaderItem for the given url.
static CssUrlReferenceHeaderItem forUrl(String url, String media, String condition)
          Creates a CssUrlReferenceHeaderItem for the given url.
 String getCondition()
           
protected  void internalRenderCSSReference(Response response, String url, String media, String condition)
           
 
Methods inherited from class org.apache.wicket.markup.head.HeaderItem
getDependencies, getProvidedResources, getRenderTokens, render
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CssHeaderItem

protected CssHeaderItem(String condition)
Method Detail

getCondition

public String getCondition()
Returns:
the condition to use for Internet Explorer conditional comments. E.g. "IE 7".

forReference

public static CssReferenceHeaderItem forReference(ResourceReference reference)
Creates a CssReferenceHeaderItem 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,
                                                  String media)
Creates a CssReferenceHeaderItem for the given reference.

Parameters:
reference - a reference to a CSS resource
media - 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 a CssReferenceHeaderItem for the given reference.

Parameters:
reference - a reference to a CSS resource
pageParameters - the parameters for this CSS resource reference
media - 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 condition)
Creates a CssReferenceHeaderItem 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 resource
pageParameters - the parameters for this CSS resource reference
media - 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.

forCSS

public static CssContentHeaderItem forCSS(CharSequence css,
                                          String id)
Creates a CssContentHeaderItem for the given content.

Parameters:
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.
Returns:
A newly created CssContentHeaderItem for the given content.

forCSS

public static CssContentHeaderItem forCSS(CharSequence css,
                                          String id,
                                          String condition)
Creates a CssContentHeaderItem 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 be null, 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(String url)
Creates a CssUrlReferenceHeaderItem 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(String url,
                                               String media)
Creates a CssUrlReferenceHeaderItem for the given url.

Parameters:
url - context-relative url of the CSS resource
media - the media type for this CSS ("print", "screen", etc.)
Returns:
A newly created CssUrlReferenceHeaderItem for the given url.

forUrl

public static CssUrlReferenceHeaderItem forUrl(String url,
                                               String media,
                                               String condition)
Creates a CssUrlReferenceHeaderItem 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 resource
media - 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.

internalRenderCSSReference

protected final void internalRenderCSSReference(Response response,
                                                String url,
                                                String media,
                                                String condition)


Copyright © 2006–2016 Apache Software Foundation. All rights reserved.