org.zkoss.zhtml.impl
Class AbstractTag

java.lang.Object
  extended by org.zkoss.zk.ui.AbstractComponent
      extended by org.zkoss.zhtml.impl.AbstractTag
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Component, DynamicPropertied, RawId, Scope, ComponentCtrl
Direct Known Subclasses:
A, Abbr, Acronym, Address, Area, B, Base, Big, Blockquote, Body, Br, Button, Caption, Center, Cite, Code, Col, Colgroup, ContentTag, Dd, Del, Dfn, Dir, Div, Dl, Dt, Em, Embed, Fieldset, Font, Form, H1, H2, H3, H4, Head, Hr, Html, I, Iframe, Img, Input, Ins, Isindex, Kbd, Label, Legend, Li, Link, Map, Menu, Meta, Nobr, Object, Ol, Optgroup, Option, P, Pre, Q, Raw, S, Samp, Select, Small, Span, Strong, Sub, Sup, Table, Tbody, Td, Tfoot, Th, Thead, Title, Tr, Tt, Ul, Var

public class AbstractTag
extends AbstractComponent
implements DynamicPropertied, RawId

The raw component used to generate raw HTML elements.

Note: ZHTML components ignore the page listener since it handles non-deferrable event listeners (see Deferrable).

Author:
tomyeh
See Also:
Serialized Form

Nested Class Summary
protected  class AbstractTag.ExtraCtrl
           
 
Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
AbstractComponent.Children
 
Field Summary
protected  java.lang.String _tagnm
          The tag name.
 
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
protected AbstractTag()
           
protected AbstractTag(java.lang.String tagname)
           
 
Method Summary
 java.lang.Object clone()
          Clones the component.
 java.lang.Object getDynamicProperty(java.lang.String name)
          Returns the dynamic property, or null if not found.
 java.lang.Object getExtraCtrl()
          Returns the extra controls that tell ZK how to handle this component specially.
 java.lang.String getSclass()
          Returns the CSS class.
 java.lang.String getStyle()
          Returns the CSS style.
 java.lang.String getTag()
          Returns the tag name.
 java.lang.String getWidgetClass()
          Returns the widget class, "zhtml.Widget".
 boolean hasDynamicProperty(java.lang.String name)
          Returns whether a dynamic property is defined.
protected  boolean isChildable()
          Returns whether this component can have a child.
protected  boolean isOrphanTag()
          Returns whether this tag is an orphan tag, i.e., it shall be in the form of <tag/>.
 void redraw(java.io.Writer out)
          Redraws this component and all its descendants.
protected  void redrawChildrenDirectly(TagRenderContext rc, Execution exec, java.io.Writer out)
          Renders the children directly to the given output.
protected  void renderProperties(ContentRenderer renderer)
          Called by (ComponentCtrl.redraw(java.io.Writer)) to render the properties, excluding the enclosing tag and children.
 void setDynamicProperty(java.lang.String name, java.lang.Object value)
          Sets the dynamic property.
 void setSclass(java.lang.String sclass)
          Sets the CSS class.
 void setStyle(java.lang.String style)
          Sets the CSS style.
 boolean setVisible(boolean visible)
          Changes the visibility of this component.
protected  boolean shallHideId()
          Whether to hide the id attribute.
 java.lang.String toString()
           
 
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addAnnotation, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addScopeListener, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableClientUpdate, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getChildren, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getStubonly, getTemplate, getTemplateNames, getUuid, getWidgetAttribute, getWidgetAttributeNames, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasFellow, hasFellow, insertBefore, invalidate, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, onWrongValue, query, queryAll, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, removeScopeListener, render, render, render, replace, response, response, response, service, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setTemplate, setVisibleDirectly, setWidgetAttribute, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, updateByClient, willPassivate, willPassivate, willSerialize, willSerialize
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_tagnm

protected java.lang.String _tagnm
The tag name.

Constructor Detail

AbstractTag

protected AbstractTag(java.lang.String tagname)

AbstractTag

protected AbstractTag()
Method Detail

getSclass

public java.lang.String getSclass()
Returns the CSS class. Due to Java's limitation, we cannot use the name called getClas.

Default: null (the default value depends on element).


setSclass

public void setSclass(java.lang.String sclass)
Sets the CSS class.


getStyle

public java.lang.String getStyle()
Returns the CSS style.

Default: null.


setStyle

public void setStyle(java.lang.String style)
Sets the CSS style.

Note: if display is not specified as part of style, the returned value of AbstractComponent.isVisible() is assumed. In other words, if not visible and dispaly is not specified as part of style, "display:none" is appended.

On the other hand, if display is specified, then setVisible(boolean) is called to reflect the visibility, if necessary.


getTag

public java.lang.String getTag()
Returns the tag name.


hasDynamicProperty

public boolean hasDynamicProperty(java.lang.String name)
Description copied from interface: DynamicPropertied
Returns whether a dynamic property is defined.

Specified by:
hasDynamicProperty in interface DynamicPropertied

getDynamicProperty

public java.lang.Object getDynamicProperty(java.lang.String name)
Returns the dynamic property, or null if not found. Note: it must be a String object or null.

Specified by:
getDynamicProperty in interface DynamicPropertied

setDynamicProperty

public void setDynamicProperty(java.lang.String name,
                               java.lang.Object value)
                        throws WrongValueException
Sets the dynamic property. Note: it converts the value to a string object (by use of Objects.toString(java.lang.Object)).

Note: it handles the style property specially. Refer to setStyle(java.lang.String) for details.

Specified by:
setDynamicProperty in interface DynamicPropertied
Throws:
WrongValueException

shallHideId

protected boolean shallHideId()
Whether to hide the id attribute.

Default: false.

Some tags, such as Html, won't generate the id attribute. They shall override this method to return true.


setVisible

public boolean setVisible(boolean visible)
Changes the visibility of this component.

Note: it will adjust the style (getStyle()) based on the visibility.

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

getWidgetClass

public java.lang.String getWidgetClass()
Returns the widget class, "zhtml.Widget".

Specified by:
getWidgetClass in interface Component
Overrides:
getWidgetClass in class AbstractComponent
Since:
5.0.0
See Also:
Component.setWidgetClass(java.lang.String)

redraw

public void redraw(java.io.Writer out)
            throws java.io.IOException
Description copied from class: AbstractComponent
Redraws this component and all its descendants.

Default: It uses JsContentRenderer to render all information in JavaScript codes. For devices that don't support JavaScript, it must override this method.

To generate all information, it first invokes AbstractComponent.renderProperties(org.zkoss.zk.ui.sys.ContentRenderer) to render component's properties, and then AbstractComponent.redrawChildren(java.io.Writer) to redraw children (and descendants) (by calling their AbstractComponent.redraw(java.io.Writer)).

If a derived class wants to render more properties, it can override AbstractComponent.renderProperties(org.zkoss.zk.ui.sys.ContentRenderer).

If a derived class renders only a subset of its children (such as paging/cropping), it could override AbstractComponent.redrawChildren(java.io.Writer).

If a deriving class wants to do something before AbstractComponent.renderProperties(org.zkoss.zk.ui.sys.ContentRenderer), it has to override AbstractComponent.redraw(java.io.Writer).

If a deriving class doesn't want to render in JavaScript codes, it has to override AbstractComponent.redraw(java.io.Writer) with the proper implementation of ContentRenderer.

Specified by:
redraw in interface ComponentCtrl
Overrides:
redraw in class AbstractComponent
Throws:
java.io.IOException

redrawChildrenDirectly

protected void redrawChildrenDirectly(TagRenderContext rc,
                                      Execution exec,
                                      java.io.Writer out)
                               throws java.io.IOException
Renders the children directly to the given output. Notice it is called only if redraw(java.io.Writer) is going to render the content (HTML tags) directly. If it is about to generate the JavaScript code AbstractComponent.redrawChildren(java.io.Writer) will be called instead.

You have to override this method if the deriving class has additional information to render.

Throws:
java.io.IOException
Since:
5.0.7

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

isChildable

protected boolean isChildable()
Description copied from class: AbstractComponent
Returns whether this component can have a child.

Default: return true (means it can have children).

Overrides:
isChildable in class AbstractComponent

isOrphanTag

protected boolean isOrphanTag()
Returns whether this tag is an orphan tag, i.e., it shall be in the form of <tag/>.

Since:
5.0.8

clone

public java.lang.Object clone()
Description copied from interface: Component
Clones the component. All of its children and descendants are cloned. Also, ID are preserved.

Specified by:
clone in interface Component
Overrides:
clone in class AbstractComponent
Returns:
the new component. Notice that it doesn't belong to any page, nor desktop. It doesn't have a parent, either.

toString

public java.lang.String toString()
Overrides:
toString in class AbstractComponent

getExtraCtrl

public java.lang.Object getExtraCtrl()
Description copied from class: AbstractComponent
Returns the extra controls that tell ZK how to handle this component specially. It is used only by component developers.

Default: null.

Specified by:
getExtraCtrl in interface ComponentCtrl
Overrides:
getExtraCtrl in class AbstractComponent
Returns:
null if no special handling required. If the component requires some special controls, it could return an object that implements one or several interfaces in the org.zkoss.zk.ui.ext.render package. For example, Cropper.
See Also:
ComponentCtrl.getExtraCtrl()


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