Package org.zkoss.zuti.zul
Class ShadowTemplate
java.lang.Object
org.zkoss.zuti.zul.ShadowTemplate
- All Implemented Interfaces:
Serializable,org.zkoss.zk.ui.ext.DynamicPropertied
public class ShadowTemplate
extends Object
implements org.zkoss.zk.ui.ext.DynamicPropertied, Serializable
A utility to let developers to apply shadow elements in Java class. It has the similar behavior with
Apply, for
example, developers can specify the template(setTemplate(String)) or pass parameters(setDynamicProperty(String, Object)).
The difference is that developers must designate a boolean value, called autodrop, to indicate whether to
drop those rendered children or not. If true, every time user changed template or detach from the original host,
ShadowTemplate will HtmlShadowElement.recreate() or removed the children, otherwise, rendered children will be remained.
After instantiating ShadowTemplate instance and above configuration, developers can trigger apply(Component) to compose
the specified template with shadow host passed as parameter. Note that, the passed host should be the same one if
autodrop is true, or pass null to detach the original host first.
- Since:
- 8.0.0
- Author:
- chunfu
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionShadowTemplate(boolean autodrop) Constructor needs a boolean value to indicate whether to detached all rendered children automatically or not when template or host is changed. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(org.zkoss.zk.ui.Component host) Compose the specified template with the given host.getDynamicProperty(String name) org.zkoss.zk.ui.ComponentReturn the current shadow host.Returns the template nameGets the template uri.booleanhasDynamicProperty(String name) voidsetDynamicProperty(String name, Object value) voidsetTemplate(String template) Sets the template name, for more detail, please check outApply.setTemplate(String)voidsetTemplateURI(String templateURI) Sets the template uri, for more detail, please check outApply.setTemplateURI(String)
-
Constructor Details
-
ShadowTemplate
public ShadowTemplate(boolean autodrop) Constructor needs a boolean value to indicate whether to detached all rendered children automatically or not when template or host is changed.- Parameters:
autodrop- a boolean value
-
-
Method Details
-
getTemplate
Returns the template nameDefault: empty string
-
setTemplate
Sets the template name, for more detail, please check outApply.setTemplate(String) -
setTemplateURI
Sets the template uri, for more detail, please check outApply.setTemplateURI(String)- Parameters:
templateURI- the template URI
-
getTemplateURI
Gets the template uri.- Returns:
- template uri
-
hasDynamicProperty
- Specified by:
hasDynamicPropertyin interfaceorg.zkoss.zk.ui.ext.DynamicPropertied
-
getDynamicProperty
- Specified by:
getDynamicPropertyin interfaceorg.zkoss.zk.ui.ext.DynamicPropertied
-
getDynamicProperties
- Specified by:
getDynamicPropertiesin interfaceorg.zkoss.zk.ui.ext.DynamicPropertied
-
setDynamicProperty
public void setDynamicProperty(String name, Object value) throws org.zkoss.zk.ui.WrongValueException - Specified by:
setDynamicPropertyin interfaceorg.zkoss.zk.ui.ext.DynamicPropertied- Throws:
org.zkoss.zk.ui.WrongValueException
-
getShadowHost
public org.zkoss.zk.ui.Component getShadowHost()Return the current shadow host.- Returns:
- host component
-
apply
public void apply(org.zkoss.zk.ui.Component host) Compose the specified template with the given host. Notice that,- If autodrop(the boolean value passed when instantiation) is true, users should apply to the same host every time, otherwise, apply null to detach the original host, and then apply to the new one.
- If autodrop is false, don't have to consider this situation, users can apply to any host you want except null.
- Parameters:
host- as known as shadow host mentioned in other shadow element
-