Package org.zkoss.zk.ui.metainfo
Class ZScriptInfo
java.lang.Object
org.zkoss.zk.ui.metainfo.ZScriptInfo
- All Implemented Interfaces:
Serializable,NodeInfo,Condition
Represents a zscript element.
- Since:
- 6.0.0
- Author:
- tomyeh
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionZScriptInfo(NodeInfo parent, String zslang, String url, org.zkoss.util.resource.Locator locator, ConditionImpl cond) Constructs aZScriptInfowith an URL, which might contain an EL expression.ZScriptInfo(NodeInfo parent, String zslang, String content, ConditionImpl cond) Creates aZScriptInfowith the content directly.ZScriptInfo(NodeInfo parent, String zslang, URL url, ConditionImpl cond) Create aZScriptInfowith an URL that is used to load the content. -
Method Summary
Modifier and TypeMethodDescriptionvoidappendChild(NodeInfo child) Append a childReturns a readonly list of children.getContent(Page page, Component comp) Returns the content of zscript.Returns the evaluator.Returns the evaluator reference.Returns the scripting language, or null if the default scripting language is preferred.Returns the page definition, i.e., the root node, or null if not available.Returns the parent, or null if it has no parent.Returns the raw content.Returns theZScriptobject hold in this info.booleanReturns whether the evaluation of the zscript shall be deferred.booleanisEffective(Component comp) Used to evaluate whether it is effective.booleanisEffective(Page page) Used to evaluate whether it is effective.booleanremoveChild(NodeInfo child) Removes a child.voidsetCondition(ConditionImpl cond) Sets the effectiveness condition.voidsetDeferred(boolean deferred) Sets whether the evaluation of the zscript shall be deferred.voidsetLanguage(String zslang) Sets the scripting language.toString()booleanTests if the condition is set
-
Constructor Details
-
ZScriptInfo
Creates aZScriptInfowith the content directly.- Parameters:
zslang- the scripting language. If null, it is the same asPage.getZScriptLanguage().content- the zscript content
-
ZScriptInfo
Create aZScriptInfowith an URL that is used to load the content.- Parameters:
url- the URL to load the content of zscript.
-
ZScriptInfo
public ZScriptInfo(NodeInfo parent, String zslang, String url, org.zkoss.util.resource.Locator locator, ConditionImpl cond) Constructs aZScriptInfowith an URL, which might contain an EL expression.- Parameters:
url- the URL. It may contain XEL expressions.locator- the locator used to locate the zscript file
-
-
Method Details
-
getZScript
Returns theZScriptobject hold in this info. -
getLanguage
Returns the scripting language, or null if the default scripting language is preferred. -
setLanguage
Sets the scripting language.- Parameters:
zslang- the scripting language. If null, the default scripting language is assume.
-
getRawContent
Returns the raw content. It is the content specified in the constructor (ZScriptInfo(NodeInfo, String, String, ConditionImpl). If URL is specified in the constructor, null is returned.On the other hand,
getContent(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Component)will load the content automatically if URL is specified.- Returns:
- the raw content specified in the constructor, or null if URL is specified instead.
-
getContent
Returns the content of zscript. If URL is specified, this method loads the content from it. If URL is an EL expression, it will be evaluated first.Note: before evaluating the returned script, you have to invoke
Condition.isEffective(Component)orCondition.isEffective(Page)first.- Parameters:
page- the page when this zscript is interpreted. Used only if this object is constructed withZScriptInfo(NodeInfo, String, String, Locator, ConditionImpl).comp- the component when this zscript is interpreted. Used only if this object is constructed withZScriptInfo(NodeInfo, String, String, Locator, ConditionImpl).- Throws:
UiException- if failed to load the content
-
isDeferred
public boolean isDeferred()Returns whether the evaluation of the zscript shall be deferred. -
setDeferred
public void setDeferred(boolean deferred) Sets whether the evaluation of the zscript shall be deferred.Default: false.
-
toString
-
setCondition
Sets the effectiveness condition. -
withCondition
public boolean withCondition()Tests if the condition is set -
isEffective
Description copied from interface:ConditionUsed to evaluate whether it is effective.- Specified by:
isEffectivein interfaceCondition- Parameters:
comp- used as the self variable. Ignored if null.
-
isEffective
Description copied from interface:ConditionUsed to evaluate whether it is effective.- Specified by:
isEffectivein interfaceCondition- Parameters:
page- used as the self variable. Ignored if null.
-
getEvaluatorRef
Description copied from interface:NodeInfoReturns the evaluator reference.- Specified by:
getEvaluatorRefin interfaceNodeInfo
-
getPageDefinition
Description copied from interface:NodeInfoReturns the page definition, i.e., the root node, or null if not available.- Specified by:
getPageDefinitionin interfaceNodeInfo
-
getEvaluator
Description copied from interface:NodeInfoReturns the evaluator.All nodes in the same ZUML tree has the same evaluator reference (inherited from the root node,
PageDefinition.getEvaluatorRef()).- Specified by:
getEvaluatorin interfaceNodeInfo
-
getParent
Description copied from interface:NodeInfoReturns the parent, or null if it has no parent. -
getChildren
Description copied from interface:NodeInfoReturns a readonly list of children.Note: the returned list is readonly. To modify, please use
NodeInfo.appendChild(org.zkoss.zk.ui.metainfo.NodeInfo)andNodeInfo.removeChild(org.zkoss.zk.ui.metainfo.NodeInfo)instead.- Specified by:
getChildrenin interfaceNodeInfo
-
appendChild
Description copied from interface:NodeInfoAppend a child- Specified by:
appendChildin interfaceNodeInfo
-
removeChild
Description copied from interface:NodeInfoRemoves a child.- Specified by:
removeChildin interfaceNodeInfo
-