Class ShadowTemplate
- java.lang.Object
-
- org.zkoss.zuti.zul.ShadowTemplate
-
- All Implemented Interfaces:
java.io.Serializable,DynamicPropertied
public class ShadowTemplate extends java.lang.Object implements DynamicPropertied, java.io.Serializable
A utility to let developers to apply shadow elements in Java class. It has the similar behavior withApply, 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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapply(Component host)Compose the specified template with the given host.java.util.Map<java.lang.String,java.lang.Object>getDynamicProperties()Returns all available dynamic properties.java.lang.ObjectgetDynamicProperty(java.lang.String name)Returns the property value of the specified name.ComponentgetShadowHost()Return the current shadow host.java.lang.StringgetTemplate()Returns the template namejava.lang.StringgetTemplateURI()Gets the template uri.booleanhasDynamicProperty(java.lang.String name)Returns whether a dynamic property is defined.voidsetDynamicProperty(java.lang.String name, java.lang.Object value)Sets a property with the specified name and value.voidsetTemplate(java.lang.String template)Sets the template name, for more detail, please check outApply.setTemplate(String)voidsetTemplateURI(java.lang.String templateURI)Sets the template uri, for more detail, please check outApply.setTemplateURI(String)
-
-
-
Method Detail
-
getTemplate
public java.lang.String getTemplate()
Returns the template nameDefault: empty string
-
setTemplate
public void setTemplate(java.lang.String template)
Sets the template name, for more detail, please check outApply.setTemplate(String)
-
setTemplateURI
public void setTemplateURI(java.lang.String templateURI)
Sets the template uri, for more detail, please check outApply.setTemplateURI(String)- Parameters:
templateURI- the template URI
-
getTemplateURI
public java.lang.String getTemplateURI()
Gets the template uri.- Returns:
- template uri
-
hasDynamicProperty
public boolean hasDynamicProperty(java.lang.String name)
Description copied from interface:DynamicPropertiedReturns whether a dynamic property is defined.- Specified by:
hasDynamicPropertyin interfaceDynamicPropertied
-
getDynamicProperty
public java.lang.Object getDynamicProperty(java.lang.String name)
Description copied from interface:DynamicPropertiedReturns the property value of the specified name.- Specified by:
getDynamicPropertyin interfaceDynamicPropertied
-
getDynamicProperties
public java.util.Map<java.lang.String,java.lang.Object> getDynamicProperties()
Description copied from interface:DynamicPropertiedReturns all available dynamic properties.- Specified by:
getDynamicPropertiesin interfaceDynamicPropertied
-
setDynamicProperty
public void setDynamicProperty(java.lang.String name, java.lang.Object value) throws WrongValueExceptionDescription 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
-
getShadowHost
public Component getShadowHost()
Return the current shadow host.- Returns:
- host component
-
apply
public void apply(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
-
-