public class ShadowTemplate extends java.lang.Object implements DynamicPropertied, java.io.Serializable
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.
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
void |
apply(Component host)
Compose the specified template with the given host.
|
java.util.Map<java.lang.String,java.lang.Object> |
getDynamicProperties() |
java.lang.Object |
getDynamicProperty(java.lang.String name)
Returns the property value of the specified name.
|
Component |
getShadowHost()
Return the current shadow host.
|
java.lang.String |
getTemplate()
Returns the template name
Default: empty string
|
java.lang.String |
getTemplateURI()
Gets the template uri.
|
boolean |
hasDynamicProperty(java.lang.String name)
Returns whether a dynamic property is defined.
|
void |
setDynamicProperty(java.lang.String name,
java.lang.Object value)
Sets a property with the specified name and value.
|
void |
setTemplate(java.lang.String template)
Sets the template name, for more detail, please check out
Apply.setTemplate(String) |
void |
setTemplateURI(java.lang.String templateURI)
Sets the template uri, for more detail, please check out
Apply.setTemplateURI(String) |
public ShadowTemplate(boolean autodrop)
autodrop
- a boolean valuepublic java.lang.String getTemplate()
Default: empty string
public void setTemplate(java.lang.String template)
Apply.setTemplate(String)
public void setTemplateURI(java.lang.String templateURI)
Apply.setTemplateURI(String)
templateURI
- the template URIpublic java.lang.String getTemplateURI()
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 java.util.Map<java.lang.String,java.lang.Object> getDynamicProperties()
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
public Component getShadowHost()
public void apply(Component host)
host
- as known as shadow host mentioned in other shadow elementCopyright © 2005-2018 Potix Corporation. All Rights Reserved.