org.zkoss.zul
Class Style

java.lang.Object
  extended by org.zkoss.zk.ui.AbstractComponent
      extended by org.zkoss.zul.Style
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Component, Scope, ComponentCtrl, Style

public class Style
extends AbstractComponent
implements Style

The style component used to specify CSS styles for the owner desktop.

Note: a style component can appear anywhere in a ZUML page, but it affects all components in the same desktop.

There are two formats when used in a ZUML page:

Method 1: Specify the URL of the CSS file

<style src="my.css"/>
 

Method 2: Specify the CSS directly

<style>
 .mycls {
  border: 1px outset #777;
 }
</style>
 

Note: if the src and content properties are both set, the later one overrides the previous one.

Author:
tomyeh
See Also:
Serialized Form

Nested Class Summary
protected  class Style.ExtraCtrl
          A utility class to implement AbstractComponent.getExtraCtrl().
 
Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
AbstractComponent.Children
 
Field Summary
 
Fields inherited from class org.zkoss.zk.ui.AbstractComponent
_visible
 
Fields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
 
Fields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE
 
Constructor Summary
Style()
           
Style(java.lang.String src)
           
 
Method Summary
 java.lang.String getContent()
          Returns the content of the style element.
 java.lang.String getSrc()
          Returns the URI of an external style sheet.
protected  boolean isChildable()
          Not childable.
 boolean isDynamic()
          Deprecated. As of release 5.0.0, it is decided automatically.
protected  java.lang.Object newExtraCtrl()
          Used by AbstractComponent.getExtraCtrl() to create extra controls.
protected  void renderProperties(ContentRenderer renderer)
          Called by (ComponentCtrl.redraw(java.io.Writer)) to render the properties, excluding the enclosing tag and children.
 void setContent(java.lang.String content)
          Sets the content of the style element.
 void setDynamic(boolean dynamic)
          Deprecated. As of release 5.0.0, it is decided automatically.
 void setSrc(java.lang.String src)
          Sets the URI of an external style sheet.
 boolean setVisible(boolean visible)
          Not allowd.
 
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addAnnotation, addClientEvent, addEventHandler, addEventListener, addForward, addForward, addForward, addForward, addMoved, addScopeListener, addSharedAnnotationMap, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, clone, containsVariable, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableClientUpdate, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getChildren, getClientEvents, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getExtraCtrl, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNamespace, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getUuid, getVariable, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasFellow, hasFellow, insertBefore, invalidate, isInvalidated, isListenerAvailable, isVisible, newChildren, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, onWrongValue, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, removeScopeListener, render, render, render, response, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setVariable, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, unsetVariable, updateByClient, willPassivate, willPassivate, willSerialize, willSerialize
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Style

public Style()

Style

public Style(java.lang.String src)
Parameters:
src - the URI of an external style sheet.
Method Detail

setDynamic

public void setDynamic(boolean dynamic)
Deprecated. As of release 5.0.0, it is decided automatically.

Description copied from interface: Style
Sets whether to load an external Style Sheet dynamically.

Default: false.

Specified by:
setDynamic in interface Style
See Also:
Style.isDynamic()

isDynamic

public boolean isDynamic()
Deprecated. As of release 5.0.0, it is decided automatically.

Description copied from interface: Style
Returns whether to load an external Style Sheet dynamically. If false, a HTML STYLE or LINK tag is generated to represent the content or the src.

Due to IE's limitation, there is no effect if the style component is added or removed dynamically and if Style.isDynamic() is false.

If Style.isDynamic() is true, this component can be added and removed dynamically and the rules will be attached and detached accordingly. Note: in this case, the HTML LINK tag is generated when this component is initialized at the client, so the style will be loaded to the client after all components are initialized.

Default: false.

Specified by:
isDynamic in interface Style

getSrc

public java.lang.String getSrc()
Returns the URI of an external style sheet.

Default: null.

Specified by:
getSrc in interface Style

setSrc

public void setSrc(java.lang.String src)
Sets the URI of an external style sheet.

Calling this method implies setContent(null). In other words, the last invocation of setSrc(java.lang.String) overrides the previous setContent(java.lang.String), if any.

Specified by:
setSrc in interface Style
Parameters:
src - the URI of an external style sheet
See Also:
setContent(java.lang.String)

getContent

public java.lang.String getContent()
Returns the content of the style element. By content we mean the CSS rules that will be sent to the client.

Default: null.

Deriving class can override this method to return whatever it prefers (ignored if null).

Specified by:
getContent in interface Style
Since:
3.0.0

setContent

public void setContent(java.lang.String content)
Sets the content of the style element. By content we mean the CSS rules that will be sent to the client.

Calling this method implies setSrc(null). In other words, the last invocation of setContent(java.lang.String) overrides the previous setSrc(java.lang.String), if any.

Specified by:
setContent in interface Style
Since:
3.0.0
See Also:
setSrc(java.lang.String)

renderProperties

protected void renderProperties(ContentRenderer renderer)
                         throws java.io.IOException
Description copied from class: AbstractComponent
Called by (ComponentCtrl.redraw(java.io.Writer)) to render the properties, excluding the enclosing tag and children.

Default: it renders AbstractComponent.getId() if it was assigned, and event names if listened (and listed in AbstractComponent.getClientEvents()).

Note: it doesn't render AbstractComponent.getWidgetClass(), AbstractComponent.getUuid() and AbstractComponent.getMold(), which are caller's job.

Overrides:
renderProperties in class AbstractComponent
Throws:
java.io.IOException

setVisible

public boolean setVisible(boolean visible)
Not allowd.

Specified by:
setVisible in interface Component
Overrides:
setVisible in class AbstractComponent
Returns:
the previous visibility

isChildable

protected boolean isChildable()
Not childable.

Overrides:
isChildable in class AbstractComponent

newExtraCtrl

protected java.lang.Object newExtraCtrl()
Description copied from class: AbstractComponent
Used by AbstractComponent.getExtraCtrl() to create extra controls. It is used only by component developers.

Default: return null.

To provide extra controls, it is simpler to override this method instead of AbstractComponent.getExtraCtrl(). By use of AbstractComponent.newExtraCtrl(), you don't need to care of cloning and serialization.

Overrides:
newExtraCtrl in class AbstractComponent


Copyright © 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo