|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.zkoss.zk.ui.AbstractComponent org.zkoss.zk.ui.HtmlBasedComponent org.zkoss.zk.ui.HtmlMacroComponent
public class HtmlMacroComponent
The implementation of a macro component for HTML-based clients.
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()
.
To do additional application-specific tasks, you could override
compose()
. Both afterCompose()
and recreate()
depends on compose()
.
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>
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlBasedComponent |
---|
HtmlBasedComponent.ExtraCtrl |
Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent |
---|
AbstractComponent.Children |
Field Summary | |
---|---|
protected java.util.List<VariableResolver> |
_resolvers
A list of resolvers (never null). |
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent |
---|
_zclass |
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 | |
---|---|
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. |
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 |
getEnclosingTag()
Returns the name of the enclosing tag for this macro component. |
java.lang.String |
getMacroURI()
Returns the macro URI. |
java.lang.String |
getWidgetClass()
Returns the component class (a.k.a., widget type), "zk.Macro". |
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 by use of compose() . |
protected void |
renderProperties(ContentRenderer renderer)
Renders the content of this component, excluding the enclosing tags and children. |
void |
setDynamicProperty(java.lang.String name,
java.lang.Object value)
Sets a property with the specified name and value. |
void |
setEnclosingTag(java.lang.String tag)
Sets the the name of the enclosing tag for this macro component. |
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. |
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent |
---|
focus, getAction, getDraggable, getDroppable, getExtraCtrl, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZindex, getZIndex, service, setAction, setClass, setDraggable, setDroppable, setFocus, setHeight, setHeightDirectly, setHflex, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setStyle, setTooltiptext, setTop, setTopDirectly, setVflex, setWidth, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly |
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, getFellow, getFellowIfAny, getFellowIfAny, getFellows, hasFellow, hasFellow |
Methods inherited from interface org.zkoss.zk.ui.ext.Scope |
---|
addScopeListener, getAttribute, getAttribute, getAttributes, hasAttribute, hasAttribute, removeAttribute, removeAttribute, removeScopeListener, setAttribute, setAttribute |
Field Detail |
---|
protected final java.util.List<VariableResolver> _resolvers
VariableResolver
was annotated.
Constructor Detail |
---|
public HtmlMacroComponent()
Method Detail |
---|
public java.lang.String getWidgetClass()
getWidgetClass
in interface Component
getWidgetClass
in class AbstractComponent
Component.setWidgetClass(java.lang.String)
public java.lang.String getEnclosingTag()
Default: span
public void setEnclosingTag(java.lang.String tag)
Default: span
public void afterCompose()
setDynamicProperty(java.lang.String, java.lang.Object)
.
If a macro component is created by ZK loader, this method is invoked automatically. Developers rarely need to invoke this method.
Default: it invokes compose()
to compose the macro component.
Instead of overriding this method, it is suggested to override
compose()
, since all other methods depend on compose()
(rather than afterCompose()
).
afterCompose
in interface AfterCompose
protected void compose()
afterCompose()
and others
to do the rendering based on getMacroURI()
.
The second invocation is ignored. If you want to recreate
child components, use recreate()
instead.
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
By default, supports auto forward events and wire accessible variables to this component.
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 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 void recreate()
compose()
.
recreate
in interface Macro
public boolean isInline()
Macro
ComponentDefinition.newInstance(org.zkoss.zk.ui.Page, java.lang.String)
.
isInline
in interface Macro
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, compose()
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 before
public 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, compose()
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 java.lang.Object clone()
Component
clone
in interface Component
clone
in class HtmlBasedComponent
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
protected void renderProperties(ContentRenderer renderer) throws java.io.IOException
HtmlBasedComponent
See also ZK Client-side Reference: Property Rendering
renderProperties
in class HtmlBasedComponent
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |