Class XmlMacroComponent
- All Implemented Interfaces:
Serializable,Cloneable,Component,AfterCompose,DynamicPropertied,Macro,Scope,IdSpace,ComponentCtrl
By default, compose() will wire members by use
of Selectors. In other words, it will wire annotated members
the same way as SelectorComposer does.
If you prefer to wire the members based on the name convention
as GenericForwardComposer does (i.e.,
backward compatible with ZK 5), you could specify a library property
called org.zkoss.zk.ui.macro.autowire.convention to true
in WEB-INF/zk.xml as follows.
<library-property>
<name>org.zkoss.zk.ui.macro.autowire.convention</name>
<value>true</value>
</library-property>
If you prefer not to wire at all (neither by-selector nor by-convention),
you could specify a library property called
org.zkoss.zk.ui.macro.autowire.disabled to true
in WEB-INF/zk.xml as follows..
<library-property>
<name>org.zkoss.zk.ui.macro.autowire.disabled</name>
<value>true</value>
</library-property>
- Since:
- 3.0.0
- Author:
- tomyeh
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
AbstractComponent.Children, AbstractComponent.ForwardInfo, AbstractComponent.TargetInfo -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<VariableResolver>A list of resolvers (never null).Fields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPEFields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_CLONED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, AFTER_PARENT_CHANGED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCreates the child components after apply dynamic propertiessetDynamicProperty(java.lang.String, java.lang.Object).clone()Clones the component.protected voidcompose()Composes the macro component.Returns all available dynamic properties.getDynamicProperty(String name) Returns the property value of the specified name.Returns the macro URI.booleanhasDynamicProperty(String name) Returns whether a dynamic property is defined.protected booleanReturns whether this component can have a child.booleanisInline()Returns whether this is an inline macro.voidrecreate()Detaches all child components and then recreate them.voidRedraws this component and all its descendants.voidsetDynamicProperty(String name, Object value) Sets a property with the specified name and value.booleansetInlineParent(Component parent, Component beforeSibling) Sets the parent to the given one and insert the children of the inline macro right before the given sibling (beforeSibling).voidsetMacroURI(String uri) Sets the macro URI.voidChanges the page.voidChanges the parent.Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, destroyIndexCacheMap, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, disableHostChanged, enableBindingAnnotation, enableHostChanged, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getExtraCtrl, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getForwards, getId, getIndexCacheMap, getLastChild, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getPropertyAccess, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getStubonlyDescendants, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, insertBefore, invalidate, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, onParentChanged, onWrongValue, query, queryAll, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderProperties, renderPropertiesOnly, replace, response, response, response, service, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPageBefore, setStubonly, setStubonly, setStubonlyDescendants, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerializeMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.zkoss.zk.ui.IdSpace
getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, hasFellow, hasFellowMethods inherited from interface org.zkoss.zk.ui.ext.Scope
addScopeListener, getAttribute, hasAttribute, removeAttribute, removeScopeListener, setAttribute
-
Field Details
-
_resolvers
A list of resolvers (never null). A variable resolver is added automatically ifVariableResolverwas annotated.
-
-
Constructor Details
-
XmlMacroComponent
public XmlMacroComponent()
-
-
Method Details
-
afterCompose
public void afterCompose()Creates the child components after apply dynamic propertiessetDynamicProperty(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)orsetPage(org.zkoss.zk.ui.Page)called- Specified by:
afterComposein interfaceAfterCompose
-
compose
protected void compose()Composes the macro component. It is called byafterCompose(), and others to do the rendering based ongetMacroURI().- Since:
- 5.0.5
-
setMacroURI
Description copied from interface:MacroSets the macro URI. It affects only this component.Note: this method calls
Macro.recreate()automatically if uri is changed.- Specified by:
setMacroURIin interfaceMacro- Parameters:
uri- the URI of this macro. If null, the default is used.
-
getMacroURI
Description copied from interface:MacroReturns the macro URI.If
Macro.setMacroURI(java.lang.String)wasn't called, it returns the URI defined in the macro definition.- Specified by:
getMacroURIin interfaceMacro
-
recreate
public void recreate()Description copied from interface:MacroDetaches all child components and then recreate them.It is used if you have assigned new values to dynamic 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 ZK Developer's Reference for details.
-
isInline
public boolean isInline()Description copied from interface:MacroReturns whether this is an inline macro. The only way to create an inline macro is by use ofComponentDefinition.newInstance(org.zkoss.zk.ui.Page, java.lang.String). -
setParent
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:
setParentin interfaceComponent- Overrides:
setParentin classAbstractComponent
-
setInlineParent
Description copied from interface:MacroSets the parent to the given one and insert the children of the inline macro right before the given sibling (beforeSibling).This method is used only internally.
Notice that when
AbstractComponent.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)is called to insert an inline macro (Macro.isInline()), the invocation will be forwarded to this method. It is called onlyMacro.isInline()is true.- Specified by:
setInlineParentin interfaceMacro- Parameters:
parent- the parentbeforeSibling- a child of the parent that the macro component will be inserted before- Returns:
- if it has been added successfully
-
setPage
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:
setPagein interfaceComponent- Overrides:
setPagein classAbstractComponent- See Also:
-
isChildable
protected boolean isChildable()Description copied from class:AbstractComponentReturns whether this component can have a child.Default: return true (means it can have children).
- Overrides:
isChildablein classAbstractComponent
-
redraw
Description copied from class:AbstractComponentRedraws this component and all its descendants.Default: It uses
JsContentRendererto 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 thenAbstractComponent.redrawChildren(java.io.Writer)to redraw children (and descendants) (by calling theirAbstractComponent.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 overrideAbstractComponent.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 ofContentRenderer.- Specified by:
redrawin interfaceComponentCtrl- Overrides:
redrawin classAbstractComponent- Throws:
IOException
-
clone
Description copied from interface:ComponentClones the component. All of its children and descendants are cloned. Also, ID are preserved.- Specified by:
clonein interfaceComponent- Overrides:
clonein classAbstractComponent- Returns:
- the new component. Notice that it doesn't belong to any page, nor desktop. It doesn't have a parent, either.
-
hasDynamicProperty
Description copied from interface:DynamicPropertiedReturns whether a dynamic property is defined.- Specified by:
hasDynamicPropertyin interfaceDynamicPropertied
-
getDynamicProperties
Description copied from interface:DynamicPropertiedReturns all available dynamic properties.- Specified by:
getDynamicPropertiesin interfaceDynamicPropertied
-
getDynamicProperty
Description copied from interface:DynamicPropertiedReturns the property value of the specified name.- Specified by:
getDynamicPropertyin interfaceDynamicPropertied
-
setDynamicProperty
Description copied from interface:DynamicPropertiedSets a property with the specified name and 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:
setDynamicPropertyin interfaceDynamicPropertied- Throws:
WrongValueException
-