public class XmlMacroComponent extends AbstractComponent implements Macro
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.
org.zkoss.zk.ui.macro.autowire.convention
true
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..
org.zkoss.zk.ui.macro.autowire.disabled
true
AbstractComponent.Children
Modifier and Type | Field and Description |
---|---|
protected java.util.List<VariableResolver> |
_resolvers
A list of resolvers (never null).
|
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE
Constructor and Description |
---|
XmlMacroComponent() |
Modifier and Type | Method and Description |
---|---|
void |
afterCompose()
Creates the child components after apply dynamic properties
setDynamicProperty(java.lang.String, java.lang.Object) . |
java.lang.Object |
clone()
Clones the component.
|
protected void |
compose()
Composes the macro component.
|
java.lang.Object |
getDynamicProperty(java.lang.String name)
Returns the property value of the specified name.
|
java.lang.String |
getMacroURI()
Returns the macro URI.
|
boolean |
hasDynamicProperty(java.lang.String name)
Returns whether a dynamic property is defined.
|
protected boolean |
isChildable()
Returns whether this component can have a child.
|
boolean |
isInline()
Returns whether this is an inline macro.
|
void |
recreate()
Detaches all child components and then recreate them.
|
void |
redraw(java.io.Writer out)
Redraws this component and all its descendants.
|
void |
setDynamicProperty(java.lang.String name,
java.lang.Object value)
Sets a property with the specified name and value.
|
boolean |
setInlineParent(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).
|
void |
setMacroURI(java.lang.String uri)
Sets the macro URI.
|
void |
setPage(Page page)
Changes the page.
|
void |
setParent(Component parent)
Changes the parent.
|
addAnnotation, addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, enableBindingAnnotation, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, 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, getId, getLastChild, getListenerIterator, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getPropertyAccess, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttribute, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, insertBefore, invalidate, invalidatePartial, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, onWrongValue, query, queryAll, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderProperties, replace, response, response, response, service, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPageBefore, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetAttribute, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, hasFellow, hasFellow
addScopeListener, getAttribute, getAttribute, getAttributes, hasAttribute, hasAttribute, removeAttribute, removeAttribute, removeScopeListener, setAttribute, setAttribute
invalidatePartial
protected final java.util.List<VariableResolver> _resolvers
VariableResolver
was annotated.public void afterCompose()
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
afterCompose
in interface AfterCompose
protected void compose()
afterCompose()
, and others
to do the rendering based on getMacroURI()
.public void setMacroURI(java.lang.String uri)
Macro
Note: this method calls Macro.recreate()
automatically
if uri is changed.
setMacroURI
in interface Macro
uri
- the URI of this macro. If null, the default is used.public java.lang.String getMacroURI()
Macro
If Macro.setMacroURI(java.lang.String)
wasn't called, it returns the URI
defined in the macro definition.
getMacroURI
in interface Macro
public void recreate()
Macro
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.
public boolean isInline()
Macro
ComponentDefinition.newInstance(org.zkoss.zk.ui.Page, java.lang.String)
.public void setParent(Component 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).
setParent
in interface Component
setParent
in class AbstractComponent
public boolean setInlineParent(Component parent, Component beforeSibling)
Macro
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 only Macro.isInline()
is true.
setInlineParent
in interface Macro
parent
- the parentbeforeSibling
- a child of the parent that the macro component
will be inserted beforepublic void setPage(Page 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).
setPage
in interface Component
setPage
in class AbstractComponent
ComponentCtrl.onPageAttached(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Page)
,
ComponentCtrl.onPageDetached(org.zkoss.zk.ui.Page)
protected boolean isChildable()
AbstractComponent
Default: return true (means it can have children).
isChildable
in class AbstractComponent
public void redraw(java.io.Writer out) throws java.io.IOException
AbstractComponent
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
.
redraw
in interface ComponentCtrl
redraw
in class AbstractComponent
java.io.IOException
public java.lang.Object clone()
Component
clone
in interface Component
clone
in class AbstractComponent
public boolean hasDynamicProperty(java.lang.String name)
DynamicPropertied
hasDynamicProperty
in interface DynamicPropertied
public java.lang.Object getDynamicProperty(java.lang.String name)
DynamicPropertied
getDynamicProperty
in interface DynamicPropertied
public void setDynamicProperty(java.lang.String name, java.lang.Object value) throws WrongValueException
DynamicPropertied
If a component supports only String-type values, it could use org.zkoss.lang.Objects.toString() to convert the value to a String instance.
setDynamicProperty
in interface DynamicPropertied
WrongValueException
Copyright © 2005-2021 Potix Corporation. All Rights Reserved.