Class HtmlShadowElement
- All Implemented Interfaces:
Serializable,Cloneable,Component,AfterCompose,Scope,ShadowElement,ShadowElementCtrl,ComponentCtrl
- Since:
- 8.0.0
- Author:
- jumperchen
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumA help class for an insertion direction.Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
AbstractComponent.Children, AbstractComponent.ForwardInfo, AbstractComponent.TargetInfo -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected Booleanprotected static final Stringprotected static final Stringstatic Stringinternal used onlyprotected static final Stringprotected static final Stringprotected static Stringprotected static final Stringprotected static final Stringstatic Stringinternal used onlyFields 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 distributed children after apply dynamic propertiesvoidafterHostChildAdded(Component child, int indexOfChild) Called when a child is added to the host.voidafterHostChildRemoved(Component child) Called when a child is removed to the host.protected static <T extends HtmlShadowElement>
TvoidbeforeChildAdded(Component child, Component refChild) Default: does nothing.voidbeforeHostChildAdded(Component child, Component insertBefore, int indexOfInsertBefore) Called before the host adding a child.voidbeforeHostChildRemoved(Component child, int indexOfChild) Called before the host removing a child.voidbeforeHostParentChanged(Component parent) Called before the host changing the parent.voidbeforeParentChanged(Component parent) Default: If parent is null, execute the @Destroy method if any.voidclone()Clones the component.protected abstract voidComposes the shadow element.voidInternal usevoiddetach()Removes the relation points between shadow host and this shadow element.Returns a list of distributed components of the shadow tree, including its descendant.Returns the first component of its insertion range.static intgetIndexCacheMap(Component host) Internal useReturns the last component of its insertion range.Returns the next insertion point, it may be a component, a shadow element, or null.Returns the next component before this shadow, if any.Returns the previous insertion point, it may be a component, a shadow element, or null.Returns the first component before this shadow, if any.Returns the owner component that hosts this shadow element.Return the shadow host from it or its ancestor, if any.protected voidinitClone(AbstractComponent cloneHost) initIndexCacheMap(Component host) Internal usestatic HtmlShadowElement.DirectioninRange(HtmlShadowElement se, Component target) Returns the direction of the target component according to the given shadow element.voidInvalidates this component by setting the dirty flag such that it will be redraw the whole content of this component and its dependencies later.booleanReturns whether the shadow element contains a dynamic value, it means the shadow element cannot be destroyed after evaluated.protected booleanisDynamicValue(String propName) Returns whether the property name contains with a dynamic value.protected abstract booleanReturns whether the shadow element is effectiveprotected voidMerge the all sub-tree into the parent's insertions, unlikeAbstractComponent.appendChild(Component)booleanmergeToHost(Component host) Merge the host into the current shadow, unlikesetShadowHost(Component, Component)voidonChildAdded(Component child) Default: handles special event listeners.protected voidonHostAttached(Component host) voidonHostChildAdded(Component child) Default: does nothing.voidonHostChildRemoved(Component child) Default: does nothing.protected voidonHostDetached(Component host) protected voidRebuilds the shadow tree if the shadow element contains a dynamic value, it should be alive, otherwise, it will be detached.voidrecreate()Detaches all child components and then recreate them by use ofcompose(org.zkoss.zk.ui.Component).protected voidresolveVariable(Component child, String name, boolean recurse) Returns the variable associated with this base component or null if not found.voidsetDynamicValue(boolean dynamicValue) Sets whether the shadow element contains a dynamic value, if true means the shadow element cannot be destroyed after evaluated, if false it will detect its attribute automatically.voidSets the parent component.protected static voidsetPrevInsertion(Component target, Component prevInsertion) voidsetShadowHost(Component host, Component insertBefore) Sets the owner component that hosts this shadow element.protected voidshrinkRange(Component firstChild, Component lastChild) protected voidstretchRange(Component firstChild, Component lastChild) toString()voidupdateFirstInsertion(Component newFirstInsertion) Updates the given first insertion to this shadow element.voidupdateLastInsertion(Component newLastInsertion) Updates the given last insertion to this shadow element.voidupdateNextInsertion(Component newNextInsertion) Updates the given next insertion to this shadow element.voidupdatePreviousInsertion(Component newPreviousInsertion) Updates the given previous insertion to this shadow element.protected voidupdateSubBindingAnnotationCount(int diff) 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, beforeChildRemoved, 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, 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, insertBefore, isChildable, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildRemoved, onPageAttached, onPageDetached, onParentChanged, onWrongValue, query, queryAll, redraw, 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, setPage, setPageBefore, setStubonly, setStubonly, setStubonlyDescendants, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, updateByClient, willPassivate, willPassivate, willSerialize, willSerialize
-
Field Details
-
_afterComposed
protected boolean _afterComposed -
ON_REBUILD_SHADOW_TREE_LATER
-
FOREACH_IN_RENDER
internal used only -
SKIP_DISTRIBUTED_CHILDREN_PROPERTY_CHANGE
internal used only -
INIT_ANNO
- See Also:
-
BIND_ANNO
- See Also:
-
LOAD_ANNO
- See Also:
-
SAVE_ANNO
- See Also:
-
REFERENCE_ANNO
- See Also:
-
BINDER
- See Also:
-
_dynamicValue
-
-
Constructor Details
-
HtmlShadowElement
public HtmlShadowElement()
-
-
Method Details
-
resolveVariable
Description copied from interface:ShadowElementCtrlReturns the variable associated with this base component or null if not found.Notice that it doesn't check any variable defined in
VariableResolver(ofPage.addVariableResolver(org.zkoss.xel.VariableResolver)).- Specified by:
resolveVariablein interfaceShadowElementCtrl- Parameters:
child- the child component of the shadow hostrecurse- whether to look up the parent shadow for the existence of the variable.
If recurse is true, it will look up all parents until found.
-
getNextInsertionComponentIfAny
Returns the next component before this shadow, if any. (it will invoke recursively from its parent.) -
getPreviousInsertionComponentIfAny
Returns the first component before this shadow, if any. (it will invoke recursively from its parent.) -
onHostAttached
-
onHostDetached
-
getNextInsertion
Returns the next insertion point, it may be a component, a shadow element, or null.- Specified by:
getNextInsertionin interfaceShadowElement- Specified by:
getNextInsertionin interfaceShadowElementCtrl
-
getPreviousInsertion
Returns the previous insertion point, it may be a component, a shadow element, or null.- Specified by:
getPreviousInsertionin interfaceShadowElement- Specified by:
getPreviousInsertionin interfaceShadowElementCtrl
-
updatePreviousInsertion
Updates the given previous insertion to this shadow element. (Internal use only)- Since:
- 10.0.0
-
updateFirstInsertion
Updates the given first insertion to this shadow element. (Internal use only)- Since:
- 10.0.0
-
updateNextInsertion
Updates the given next insertion to this shadow element. (Internal use only)- Since:
- 10.0.0
-
updateLastInsertion
Updates the given last insertion to this shadow element. (Internal use only)- Since:
- 10.0.0
-
getFirstInsertion
Returns the first component of its insertion range.- Specified by:
getFirstInsertionin interfaceShadowElement- Specified by:
getFirstInsertionin interfaceShadowElementCtrl
-
getLastInsertion
Returns the last component of its insertion range.- Specified by:
getLastInsertionin interfaceShadowElement- Specified by:
getLastInsertionin interfaceShadowElementCtrl
-
setShadowHost
Description copied from interface:ShadowElementCtrlSets the owner component that hosts this shadow element.- Specified by:
setShadowHostin interfaceShadowElementCtrl- Parameters:
host- the host of the shadow elementinsertBefore- a component or a shadow element to indicate where the shadow's insertion point is added.
-
detach
public void detach()Removes the relation points between shadow host and this shadow element.- Specified by:
detachin interfaceComponent- Specified by:
detachin interfaceShadowElement- Overrides:
detachin classAbstractComponent
-
setParent
Description copied from interface:ComponentSets the parent component.Note:
Component.setParent(org.zkoss.zk.ui.Component)always calls backComponent.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)and/orComponent.removeChild(org.zkoss.zk.ui.Component), whileComponent.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)andComponent.removeChild(org.zkoss.zk.ui.Component)always calls backComponent.setParent(org.zkoss.zk.ui.Component), if the parent is changed. Thus, you don't need to override bothComponent.insertBefore(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)andComponent.setParent(org.zkoss.zk.ui.Component), if you want to customize the behavior.- Specified by:
setParentin interfaceComponent- Overrides:
setParentin classAbstractComponent
-
beforeParentChanged
Description copied from class:AbstractComponentDefault: If parent is null, execute the @Destroy method if any.- Specified by:
beforeParentChangedin interfaceComponentCtrl- Overrides:
beforeParentChangedin classAbstractComponent- Parameters:
parent- the new parent. If null, it means detachment.- See Also:
-
beforeChildAdded
Description copied from class:AbstractComponentDefault: does nothing.- Specified by:
beforeChildAddedin interfaceComponentCtrl- Overrides:
beforeChildAddedin classAbstractComponent- Parameters:
child- the child to be added (never null).refChild- another child component that the new child will be inserted before it. If null, the new child will be the last child.- See Also:
-
onChildAdded
Description copied from class:AbstractComponentDefault: handles special event listeners.- Specified by:
onChildAddedin interfaceComponentCtrl- Overrides:
onChildAddedin classAbstractComponent- See Also:
-
invalidate
public void invalidate()Description copied from interface:ComponentInvalidates this component by setting the dirty flag such that it will be redraw the whole content of this component and its dependencies later. And, the widget associated with this component and all its descendant at the client will be deleted and recreated, too.If the application is totally controlled by the server side (i.e., you don't write client codes), you rarely need to access this method.
It can be called only in the request-processing and event-processing phases. However, it is NOT allowed in the rendering phase.
- Specified by:
invalidatein interfaceComponent- Overrides:
invalidatein classAbstractComponent
-
stretchRange
-
shrinkRange
-
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.
-
initClone
-
getShadowHost
Description copied from interface:ShadowElementReturns the owner component that hosts this shadow element.- Specified by:
getShadowHostin interfaceShadowElement
-
afterCompose
public void afterCompose()Creates the distributed children after apply dynamic propertiesIf a shadow element is created by ZK loader, this method is invoked automatically. Developers rarely need to invoke this method.
Default: it invokes
compose(org.zkoss.zk.ui.Component)to compose the shadow element.The method will invoke the following methods in order.
- Check if
isEffective()to be true. - If true, invokes
compose(org.zkoss.zk.ui.Component)method to create the distributed children, otherwise, nothing happened.
Instead of overriding this method, it is suggested to override
compose(org.zkoss.zk.ui.Component), since all other methods depend oncompose(org.zkoss.zk.ui.Component)(rather thanafterCompose()).- Specified by:
afterComposein interfaceAfterCompose
- Check if
-
setPrevInsertion
-
mergeSubTree
protected void mergeSubTree()Merge the all sub-tree into the parent's insertions, unlikeAbstractComponent.appendChild(Component) -
mergeToHost
Merge the host into the current shadow, unlikesetShadowHost(Component, Component)- Parameters:
host-
-
rebuildSubShadowTree
protected void rebuildSubShadowTree()Rebuilds the shadow tree if the shadow element contains a dynamic value, it should be alive, otherwise, it will be detached.- Throws:
ConcurrentModificationException- if caller use the same collection, it may throw this exception when merging sub-tree.
-
isEffective
protected abstract boolean isEffective()Returns whether the shadow element is effective -
compose
Composes the shadow element. It is called byafterCompose()if the shadow host is not null. Otherwise, it will skip this method call.The second invocation is ignored. If you want to recreate child components, use
recreate()instead.- Parameters:
host- the shadow host component, never null.
-
beforeHostChildRemoved
Description copied from interface:ShadowElementCtrlCalled before the host removing a child.- Specified by:
beforeHostChildRemovedin interfaceShadowElementCtrl- Parameters:
child- the child to be removed (never null)indexOfChild- the index of the removed child
-
onHostChildRemoved
Default: does nothing.- Specified by:
onHostChildRemovedin interfaceShadowElementCtrl- See Also:
-
onHostChildAdded
Default: does nothing.- Specified by:
onHostChildAddedin interfaceShadowElementCtrl- See Also:
-
beforeHostParentChanged
Description copied from interface:ShadowElementCtrlCalled before the host changing the parent.- Specified by:
beforeHostParentChangedin interfaceShadowElementCtrl- Parameters:
parent- the new parent. If null, it means detachment.
-
beforeHostChildAdded
Description copied from interface:ShadowElementCtrlCalled before the host adding a child.- Specified by:
beforeHostChildAddedin interfaceShadowElementCtrl- Parameters:
child- the child to be added (never null).insertBefore- another child component that the new child will be inserted before it. If null, the new child will be the last child.indexOfInsertBefore- the index of the insertBefore, if any. Otherwise -1 is assumed.
-
asShadow
-
getIndex
public static int getIndex(ShadowElement owner, Component insertion, Map<Component, Integer> cacheMap) -
inRange
Returns the direction of the target component according to the given shadow element.- Parameters:
se- the shadow elementtarget- the target to check.
-
afterHostChildAdded
Description copied from interface:ShadowElementCtrlCalled when a child is added to the host.- Specified by:
afterHostChildAddedin interfaceShadowElementCtrl- Parameters:
child- the child has been added (never null).indexOfChild- the index of the added child.
-
afterHostChildRemoved
Description copied from interface:ShadowElementCtrlCalled when a child is removed to the host.- Specified by:
afterHostChildRemovedin interfaceShadowElementCtrl- Parameters:
child- the child has been added (never null).
-
recreate
public void recreate()Detaches all child components and then recreate them by use ofcompose(org.zkoss.zk.ui.Component).- Specified by:
recreatein interfaceShadowElement
-
clearChildren
public void clearChildren() -
removeFromParent
protected void removeFromParent() -
getShadowHostIfAny
Description copied from interface:ShadowElementCtrlReturn the shadow host from it or its ancestor, if any.- Specified by:
getShadowHostIfAnyin interfaceShadowElementCtrl- Returns:
- null or a host component
-
getDistributedChildren
Description copied from interface:ShadowElementReturns a list of distributed components of the shadow tree, including its descendant.It's better to manipulate with the component children from the host component.
- Specified by:
getDistributedChildrenin interfaceShadowElement- Returns:
- a list of distributed components (removeable only)
-
isDynamicValue
Returns whether the property name contains with a dynamic value. -
isDynamicValue
public boolean isDynamicValue()Description copied from interface:ShadowElementCtrlReturns whether the shadow element contains a dynamic value, it means the shadow element cannot be destroyed after evaluated.- Specified by:
isDynamicValuein interfaceShadowElementCtrl
-
setDynamicValue
public void setDynamicValue(boolean dynamicValue) Sets whether the shadow element contains a dynamic value, if true means the shadow element cannot be destroyed after evaluated, if false it will detect its attribute automatically.Default: false (auto detection)
- Specified by:
setDynamicValuein interfaceShadowElementCtrl- Since:
- 8.0.1
-
toString
- Overrides:
toStringin classAbstractComponent
-
updateSubBindingAnnotationCount
protected void updateSubBindingAnnotationCount(int diff) - Overrides:
updateSubBindingAnnotationCountin classAbstractComponent
-
initIndexCacheMap
Internal use- Overrides:
initIndexCacheMapin classAbstractComponent- Since:
- 10.0.0
-
getIndexCacheMap
Internal use- Overrides:
getIndexCacheMapin classAbstractComponent- Since:
- 10.0.0
-
destroyIndexCacheMap
Internal use- Overrides:
destroyIndexCacheMapin classAbstractComponent- Since:
- 10.0.0
-