org.zkoss.zk.ui
Class HtmlMacroComponent

java.lang.Object
  extended by org.zkoss.zk.ui.AbstractComponent
      extended by org.zkoss.zk.ui.HtmlBasedComponent
          extended by org.zkoss.zk.ui.HtmlMacroComponent
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Component, AfterCompose, DynamicPropertied, Macro, IdSpace, ComponentCtrl

public class HtmlMacroComponent
extends HtmlBasedComponent
implements Macro

The implemetation of a macro component upon HTML.

Generally, a macro component is created automatically by ZK loader. If a developer wants to create it manually, it has to instantiate from the correct class, and then invoke afterCompose().

Author:
tomyeh
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlBasedComponent
HtmlBasedComponent.ExtraCtrl
 
Field Summary
 
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
RS_NO_DISPLAY, RS_NO_HEIGHT, RS_NO_WIDTH
 
Fields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
 
Constructor Summary
HtmlMacroComponent()
           
 
Method Summary
 void afterCompose()
          Creates the child components after apply dynamic properties setDynamicProperty(java.lang.String, java.lang.Object).
 java.lang.Object clone()
          Clones the component.
 java.lang.Object getDynamicProperty(java.lang.String name)
          Returns the property value of the specified name.
 boolean hasDynamicProperty(java.lang.String name)
          Returns whether a dynamic attribute is allowed.
 boolean isChildable()
          Default: return true (allows to have children).
 boolean isInline()
          Returns whether this is an inline macro.
 void recreate()
          Detaches all child components and then recreate them by use of AfterCompose.afterCompose().
 void setDynamicProperty(java.lang.String name, java.lang.Object value)
          Sets an attribute with a value.
 void setMacroURI(java.lang.String uri)
          Sets the macro URI.
 void setPage(Page page)
          Changes the page.
 void setParent(Component parent)
          Changes the parent.
 
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addEventListener, appendAsapAttr, focus, getDraggable, getDroppable, getHeight, getInnerAttrs, getLeft, getOuterAttrs, getRealStyle, getRealStyleFlags, getSclass, getStyle, getTooltiptext, getTop, getWidth, getZIndex, isAsapRequired, newExtraCtrl, removeEventListener, setClass, setDraggable, setDroppable, setHeight, setLeft, setSclass, setStyle, setTooltiptext, setTop, setWidth, setZIndex
 
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addAnnotation, addEventHandler, addSharedAnnotationMap, addSharedEventHandlerMap, appendChild, applyProperties, containsVariable, detach, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttributes, getAttributes, getChildren, getDefinition, getDesktop, getEventHandler, getExtraCtrl, getFellow, getFellowIfAny, getId, getListenerIterator, getMold, getMoldURI, getNamespace, getPage, getParent, getPropagatee, getRoot, getSpaceOwner, getUuid, getVariable, insertBefore, invalidate, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onDrawNewChild, onWrongValue, redraw, removeAttribute, removeAttribute, removeChild, response, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setComponentDefinition, setId, setMold, setVariable, setVisible, smartUpdate, smartUpdate, smartUpdate, toString, unsetVariable
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.zkoss.zk.ui.IdSpace
getFellow, getFellowIfAny
 

Constructor Detail

HtmlMacroComponent

public HtmlMacroComponent()
Method Detail

afterCompose

public void afterCompose()
Creates the child components after apply dynamic properties setDynamicProperty(java.lang.String, java.lang.Object).

The second invocation is ignored. If you want to recreate child components, use recreate() instead.

If a macro component is created by ZK loader, this method is invoked automatically. Developers need to invoke this method only if they create a macro component manually.

If this is an line macro, this method is invoked automatically if setParent(org.zkoss.zk.ui.Component) or setPage(org.zkoss.zk.ui.Page) called

Specified by:
afterCompose in interface AfterCompose

setMacroURI

public void setMacroURI(java.lang.String uri)
Description copied from interface: Macro
Sets the macro URI. It affects only this component.

Note: this method calls Macro.recreate() automatically if uri is changed.

Specified by:
setMacroURI in interface Macro
Parameters:
uri - the URI of this macro. If null, the default is used.

recreate

public void recreate()
Description copied from interface: Macro
Detaches all child components and then recreate them by use of AfterCompose.afterCompose().

It is used if you have assigned new values to dynamical properties and want to re-create child components to reflect the new values. Note: it is convenient but the performance is better if you can manipulate only the child components that need to be changed. Refer to the Developer's Guide for details.

Specified by:
recreate in interface Macro

isInline

public boolean isInline()
Description copied from interface: Macro
Returns whether this is an inline macro. The only way to create an inline macro is by use of ComponentDefinition.newInstance(org.zkoss.zk.ui.Page, java.lang.String).

Specified by:
isInline in interface Macro

setParent

public void setParent(Component parent)
Changes the parent.

Note: if this is an inline macro (isInline()), this method actually changes the parent of all components created from the macro URI. In other word, an inline macro behaves like a controller of the components it created. It doesn't belong to any page or parent. Moreover, afterCompose() is called automatically if it is not called (and this is an inline macro).

Specified by:
setParent in interface Component
Overrides:
setParent in class AbstractComponent

setPage

public void setPage(Page page)
Changes the page.

Note: if this is an inline macro (isInline()), this method actually changes the page of all components created from the macro URI. In other word, an inline macro behaves like a controller of the components it created. It doesn't belong to any page or parent. Moreover, afterCompose() is called automatically if it is not called (and this is an inline macro).

Specified by:
setPage in interface Component
Overrides:
setPage in class AbstractComponent

isChildable

public boolean isChildable()
Description copied from class: AbstractComponent
Default: return true (allows to have children).

Specified by:
isChildable in interface Component
Overrides:
isChildable in class AbstractComponent

clone

public java.lang.Object clone()
Description copied from interface: Component
Clones the component. All of its children is cloned. Notice that the cloned component doesn't belong to any page, nor desktop. It doesn't have parent, either.

Specified by:
clone in interface Component
Overrides:
clone in class AbstractComponent

hasDynamicProperty

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

Specified by:
hasDynamicProperty in interface DynamicPropertied

getDynamicProperty

public java.lang.Object getDynamicProperty(java.lang.String name)
Description copied from interface: DynamicPropertied
Returns the property value of the specified name.

Specified by:
getDynamicProperty in interface DynamicPropertied

setDynamicProperty

public void setDynamicProperty(java.lang.String name,
                               java.lang.Object value)
                        throws WrongValueException
Description copied from interface: DynamicPropertied
Sets an attribute with a value.

If a component supports only String-type values, it could use org.zkoss.lang.Objects.toString() to convert the value to a String instance.

Specified by:
setDynamicProperty in interface DynamicPropertied
Throws:
WrongValueException


Copyright © 2005-2007 Potix Corporation. All Rights Reserved.