org.apache.click.element
Class CssImport

java.lang.Object
  extended by org.apache.click.element.Element
      extended by org.apache.click.element.ResourceElement
          extended by org.apache.click.element.CssImport
All Implemented Interfaces:
Serializable

public class CssImport
extends ResourceElement

Provides a Css HEAD element for importing external Cascading Stylesheet files using the <link> tag.

Example usage:

 public class MyPage extends Page {

     public List getHeadElements() {
         // We use lazy loading to ensure the CSS import is only added the
         // first time this method is called.
         if (headElements == null) {
             // Get the head elements from the super implementation
             headElements = super.getHeadElements();

             CssImport cssImport = new CssImport("/css/style.css");
             headElements.add(cssImport);
         }
         return headElements;
     }
 } 
The cssImport instance will be rendered as follows (assuming the context path is myApp):
 <link type="text/css" rel="stylesheet" href="/myApp/css/style.css"/> 

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.click.element.ResourceElement
IF_IE, IF_IE7, IF_LESS_THAN_IE7, IF_LESS_THAN_IE9, IF_LESS_THAN_OR_EQUAL_TO_IE7
 
Constructor Summary
CssImport()
          Constructs a new Css import element.
CssImport(String href)
          Construct a new Css import element with the specified href attribute.
CssImport(String href, boolean useApplicationVersionIndicator)
          Construct a new Css import element with the specified href attribute.
CssImport(String href, String versionIndicator)
          Construct a new Css import element with the specified href attribute and version indicator.
 
Method Summary
 boolean equals(Object o)
           
 String getHref()
          Return the href attribute.
 String getTag()
          Returns the Css import HTML tag: <link>.
 int hashCode()
           
 boolean isUnique()
          This method always return true because Css import must be unique based on its href attribute.
 void render(HtmlStringBuffer buffer)
          Render the HTML representation of the CssImport element to the specified buffer.
 void setHref(String href)
          Sets the href attribute.
 
Methods inherited from class org.apache.click.element.ResourceElement
getConditionalComment, getVersionIndicator, isRenderId, setConditionalComment, setRenderId, setVersionIndicator
 
Methods inherited from class org.apache.click.element.Element
appendAttributes, getAttribute, getAttributes, getContext, getId, hasAttribute, hasAttributes, setAttribute, setId, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CssImport

public CssImport()
Constructs a new Css import element.

The CssImport version indicator will automatically be set to the application version indicator.


CssImport

public CssImport(String href)
Construct a new Css import element with the specified href attribute.

The CssImport version indicator will automatically be set to the application version indicator.

Please note if the given href begins with a "/" character the href will be prefixed with the web application context path.

Parameters:
href - the Css import href attribute

CssImport

public CssImport(String href,
                 boolean useApplicationVersionIndicator)
Construct a new Css import element with the specified href attribute.

If useApplicationVersionIndicator is true the CssImport version indicator will automatically be set to the application version indicator.

Please note if the given href begins with a "/" character the href will be prefixed with the web application context path.

Parameters:
href - the Css import href attribute
useApplicationVersionIndicator - indicates whether the version indicator will automatically be set to the application version indicator

CssImport

public CssImport(String href,
                 String versionIndicator)
Construct a new Css import element with the specified href attribute and version indicator.

Please note if the given href begins with a "/" character the href will be prefixed with the web application context path.

Parameters:
href - the Css import href attribute
versionIndicator - the version indicator to add to the href path
Method Detail

getTag

public String getTag()
Returns the Css import HTML tag: <link>.

Overrides:
getTag in class Element
Returns:
the Css import HTML tag: <link>

isUnique

public boolean isUnique()
This method always return true because Css import must be unique based on its href attribute. In other words the Page HEAD should only contain a single CSS import for the specific href.

Overrides:
isUnique in class ResourceElement
Returns:
true because Css import must unique based on its href attribute
See Also:
ResourceElement.isUnique()

setHref

public void setHref(String href)
Sets the href attribute. If the given href argument is null, the href attribute will be removed.

If the given href begins with a "/" character the href will be prefixed with the web applications context path. Note if the given href is already prefixed with the context path, Click won't add it a second time.

Parameters:
href - the new href attribute

getHref

public String getHref()
Return the href attribute.

Returns:
the href attribute

render

public void render(HtmlStringBuffer buffer)
Render the HTML representation of the CssImport element to the specified buffer.

Overrides:
render in class ResourceElement
Parameters:
buffer - the buffer to render output to

equals

public boolean equals(Object o)
Overrides:
equals in class Object
Parameters:
o - the object with which to compare this instance with
Returns:
true if the specified object is the same as this object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object
Returns:
a hash code value for this object
See Also:
Object.hashCode()