|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.zkoss.zk.ui.metainfo.NodeInfo
org.zkoss.zk.ui.metainfo.ComponentInfo
public class ComponentInfo
Represents a componennt instance defined in a ZUML page.
Though serializable, we can restore getPageDefinition()
correctly after deserialized.
Note:it is not thread-safe.
It is serializable.
Constructor Summary | |
---|---|
ComponentInfo()
This constructor is used only for Externalizable . |
|
ComponentInfo(EvaluatorRef evalr,
ComponentDefinition compdef,
java.lang.String tag)
Constructs the info that doesn't have a parent. |
|
ComponentInfo(NodeInfo parent,
ComponentDefinition compdef)
Constructs the info about how to create a component that is not a dynamic tag. |
|
ComponentInfo(NodeInfo parent,
ComponentDefinition compdef,
java.lang.String tag)
Constructs the information about how to create component. |
Method Summary | |
---|---|
void |
addAnnotation(java.lang.String annotName,
java.util.Map annotAttrs)
Associates an annotation to this component info. |
void |
addAnnotation(java.lang.String propName,
java.lang.String annotName,
java.util.Map annotAttrs)
Adds an annotation to the specified proeprty of this component info. |
void |
addEventHandler(java.lang.String name,
ZScript zscript,
ConditionImpl cond)
Adds an event handler. |
void |
addProperty(java.lang.String name,
NativeInfo value,
ConditionImpl cond)
Adds a property initializer based on the native content. |
void |
addProperty(java.lang.String name,
java.lang.String value,
ConditionImpl cond)
Adds a property initializer. |
void |
addWidgetListener(java.lang.String name,
java.lang.String script,
ConditionImpl cond)
Adds an event listener for the peer widget. |
void |
addWidgetOverride(java.lang.String name,
java.lang.String script,
ConditionImpl cond)
Adds a method or a value to the peer widget. |
void |
appendChild(TextInfo text)
Adds a Sting child. |
void |
applyProperties(Component comp)
Applies the event handlers and properties to the specified component. |
java.lang.Object |
clone()
Clones this info. |
ComponentInfo |
duplicate()
Duplicates the specified component info but retaining the same but virtual parent-child relationship. |
java.util.Map |
evalProperties(java.util.Map propmap,
Page owner,
Component parent,
boolean defIncluded)
Evaluates and retrieves properties to the specified map from ComponentDefinition (and ComponentInfo ). |
AnnotationMap |
getAnnotationMap()
Returns the annotation map defined in this info, or null if no annotation is ever defined. |
java.lang.String |
getApply()
Returns the apply attribute that is a list of Composer class
names or EL expressions returning classes, class names or composer
instances, or null if no apply attribute. |
ComponentDefinition |
getComponentDefinition()
Returns the component definition, or null if it is PageDefinition. |
Evaluator |
getEvaluator()
Returns the evaluator. |
protected EvaluatorRef |
getEvaluatorRef()
Returns the evaluator reference (never null). |
java.util.Set |
getEventHandlerNames()
Returns a readonly collection of event names (String), or an empty collection if no event name is registered. |
java.lang.String |
getForward()
Returns the forward condition that controls how to forward an event, that is received by the component created by this info, to another component. |
java.lang.String |
getFulfill()
Returns the fulfill condition that controls when to create the child components, or null if the child components are created at the time when the page is loaded. |
java.lang.String |
getImplementation()
Returns the class name or an expression returning a class instance, a class name, or a component. |
LanguageDefinition |
getLanguageDefinition()
Returns the language definition that getComponentDefinition()
belongs to, or null if the component definition is temporary. |
PageDefinition |
getPageDefinition()
Returns the page definition, or null if not available. |
NodeInfo |
getParent()
Returns the parent, or null if no parent. |
java.util.List |
getProperties()
Returns a readonly list of properties ( Property ) (never null). |
java.lang.String |
getReplaceableText()
Returns the replaceable text, nor null if it cannot be replaced with a text. |
java.lang.String |
getTag()
Returns the tag name, or null if no tag name. |
java.lang.String |
getTextAs()
Returns the property name to which the text enclosed within the element (associated with this component definition) is assigned to. |
boolean |
isBlankPreserved()
Returns whether to preserve the blank text. |
boolean |
isEffective(Component comp)
Used to evaluate whether it is effective. |
boolean |
isEffective(Page page)
Used to evaluate whether it is effective. |
Component |
newInstance(Page page)
Creates an component based on this info (never null). |
Component |
newInstance(Page page,
Component parent)
Creates an component based on this info (never null). |
void |
readExternal(java.io.ObjectInput in)
Don't override this method. |
Composer |
resolveComposer(Page page,
Component comp)
Returns the composer for this info, or nuull if not available. |
ForEach |
resolveForEach(Page page,
Component comp)
Returns the forEach object if the forEach attribute is defined (or setForEach(java.lang.String, java.lang.String, java.lang.String) is called). |
java.lang.Class |
resolveImplementationClass(Page page)
Resolves and returns the class for the component represented by this info (never null). |
java.lang.Class |
resolveImplementationClass(Page page,
Component parent)
Resolves and returns the class for the component represented by this info (never null). |
void |
setApply(java.lang.String apply)
Sets the apply attribute that is is a list of Composer class
or EL expressions returning classes, class names or composer instances. |
void |
setCondition(ConditionImpl cond)
Sets the effectiveness condition. |
void |
setForEach(java.lang.String expr,
java.lang.String begin,
java.lang.String end)
Sets the forEach attribute, which is usually an expression. |
void |
setForward(java.lang.String forward)
Sets the forward condition that controls when to forward an event receiving by this component to another component. |
void |
setFulfill(java.lang.String fulfill)
Sets the fulfill condition that controls when to create the child components. |
void |
setImplementation(java.lang.String expr)
Sets the string that implements the component. |
void |
setParent(NodeInfo parent)
Sets the parent. |
void |
setReplaceableText(java.lang.String text)
Sets the replaceable text. |
java.lang.String |
toString()
|
boolean |
withCondition()
Tests if the condition is set |
boolean |
withForEach()
Returns whether the forEach condition is defined. |
void |
writeExternal(java.io.ObjectOutput out)
|
Methods inherited from class org.zkoss.zk.ui.metainfo.NodeInfo |
---|
appendChild, appendChild, appendChild, appendChild, getChildren, removeChild, removeChild, removeChild, removeChild |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ComponentInfo(NodeInfo parent, ComponentDefinition compdef, java.lang.String tag)
parent
- the parent; never null.compdef
- the component definition; never nulltag
- the tag name; Note: if component implements
DynamicTag
, this argument must be specified.
If DynamicTag
is not implemented, this argument must
be null.public ComponentInfo(NodeInfo parent, ComponentDefinition compdef)
parent
- the parent; never null.public ComponentInfo()
Externalizable
.
Don't call it, otherwise.
public ComponentInfo(EvaluatorRef evalr, ComponentDefinition compdef, java.lang.String tag)
Method Detail |
---|
public LanguageDefinition getLanguageDefinition()
getComponentDefinition()
belongs to, or null if the component definition is temporary.
public ComponentDefinition getComponentDefinition()
public void appendChild(TextInfo text)
NativeInfo
or getComponentDefinition()
is ZkInfo.ZK
.
java.lang.IllegalStateException
- if this is not an instance of
NativeInfo
, nor getComponentDefinition()
is not
ZkInfo.ZK
.public java.lang.String getTag()
public void setParent(NodeInfo parent)
public java.lang.String getTextAs()
Default: null (means to create a Label component as the child)
ComponentDefinition.getTextAs()
public boolean isBlankPreserved()
Default: false.
public java.lang.String getReplaceableText()
By replaceable text we mean the component can be replaced by a text (aka., string). ZK uses it to optimize the output by generating some content directly.
The replaceable text must be a string consisting of whitespaces only.
PrologAllowed
public void setReplaceableText(java.lang.String text)
text
- the text that can be used to replace the component
being generated by this info. If null, it means no way to
replace it with text.PrologAllowed
public java.lang.String getFulfill()
Default: null.
There are several forms:
"eventName", "targetId.evetName", "id1/id2.evetName",
and "${elExpr}.eventName".
Since 3.0.2, you can specify a list of fulfill conditions by
separating them with comma. For example:
"id1.event1, id2/id3.event2"
If not null, the child components specified in
NodeInfo.getChildren()
are created, when the event sepcified in
the fulfill condition is received at the first time.
It is the value specified in the fulfill attribute.
public void setFulfill(java.lang.String fulfill)
If not null, the child components specified in
NodeInfo.getChildren()
are created, when the event sepcified in
the fulfill condition is received at the first time.
fulfill
- the fulfill condition. There are several forms:Since 3.0.2, you can specify a list of fulfill conditions by
separating them with comma. For example:
"id1.event1, id2/id3.event2"
Since 3.5.0, you can specify the URI to fulfill with. For example:
"id1.event1=/my/super.zul".
public Composer resolveComposer(Page page, Component comp)
comp
- the component used as the self variable to resolve
EL expressions, if any.
Notice that UI engine uses the parent component for this argument.
If comp is null, the page is used as the parent component.
If comp is not null, it is used as the self variable.getApply()
public java.lang.String getApply()
Composer
class
names or EL expressions returning classes, class names or composer
instances, or null if no apply attribute.
resolveComposer(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Component)
public void setApply(java.lang.String apply)
Composer
class
or EL expressions returning classes, class names or composer instances.
apply
- the attribute this is a list of Composer
class
or EL expressions
El expressions are allowed, but self means the parent, if available;
or page, if no parent at all. (Note: the component is not created yet
when the apply attribute is evaluated).public java.lang.String getForward()
Default: null.
If not null, when the component created by this info receives the event specified in the forward condition, it will forward it to the target component, which is also specified in the forward condition.
setForward(java.lang.String)
public void setForward(java.lang.String forward)
The basic format:
onEvent1=id1/id2.onEvent2
It means when onEvent1 is received, onEvent2 will be posted to the component with the specified path (id1/id2).
If onEvent1 is omitted, it is assumed to be onClick (and
the equal sign need not to be specified.
If the path is omitted, it is assumed to be the space owner
Component.getSpaceOwner()
.
For example, "onOK" means "onClick=onOK".
You can specify several forward conditions by separating them with comma as follows:
onChanging=onChanging,onChange=onUpdate,onOK
forward
- the forward condition. There are several forms:
"onEvent1", "target.onEvent1" and "onEvent1(target.onEvent2)",
where target could be "id", "id1/id2" or "${elExpr}".
The EL expression must return either a path or a reference to
a component.public java.util.List getProperties()
Property
) (never null).
public void addProperty(java.lang.String name, java.lang.String value, ConditionImpl cond)
name
- the member name. The component must have a valid setter
for it.value
- the value. It might contain expressions (${}).public void addProperty(java.lang.String name, NativeInfo value, ConditionImpl cond)
NativeInfo
.
value
- the property value represented by NativeInfo
.public void addEventHandler(java.lang.String name, ZScript zscript, ConditionImpl cond)
name
- the event name.zscript
- the script.public java.util.Set getEventHandlerNames()
To add an event handler, use addEventHandler(java.lang.String, org.zkoss.zk.ui.metainfo.ZScript, org.zkoss.zk.ui.util.ConditionImpl)
instead.
public void addWidgetListener(java.lang.String name, java.lang.String script, ConditionImpl cond)
public void addWidgetOverride(java.lang.String name, java.lang.String script, ConditionImpl cond)
$name
so can you access it for callback purpose.
<label w:setValue="function (value) {
this.$setValue(value); //old method
}"/>
public void setCondition(ConditionImpl cond)
public boolean withCondition()
public ForEach resolveForEach(Page page, Component comp)
setForEach(java.lang.String, java.lang.String, java.lang.String)
is called).
If comp is not null, both pagedef and page are ignored. If comp is null, page must be specified.
page
- the page. It is used only if comp is null.comp
- the component.
public void setForEach(java.lang.String expr, java.lang.String begin, java.lang.String end)
expr
- the expression to return a collection of objects, or
null/empty to denote no iteration.public boolean withForEach()
public java.lang.String getImplementation()
setImplementation(java.lang.String)
was called.
To resolve the real implementation class, use
resolveImplementationClass(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Component)
.
Notice that, if a component is returned by the expression, it shall not be assigned to any page.
public void setImplementation(java.lang.String expr)
expr
- the class name, or an expression returning a class instance,
a class name, or a component instance.public Component newInstance(Page page, Component parent)
Like ComponentDefinition.newInstance(org.zkoss.zk.ui.Page, java.lang.String)
,
this method doesn't invoke applyProperties(org.zkoss.zk.ui.Component)
.
It is caller's job to invoke them if necessary.
Since the value of properties might depend on the component tree,
it is better to assign the component with a proper parent
before calling applyProperties(org.zkoss.zk.ui.Component)
.
public Component newInstance(Page page)
If the implementation class (getImplementation()
)
doesn't have any EL expression, or its EL expresson doesn't
referece to the self variable, the result is the same.
This method is preserved for backward compatibility.
It is better to use newInstance(Page, Component)
.
public java.lang.Class resolveImplementationClass(Page page, Component parent) throws java.lang.ClassNotFoundException
Unlike getImplementation()
,
this method will resolve a class name (String) to a class (Class),
if necessary.
page
- the page to check whether the class is defined
in its interpreters. Ignored if null.
This method will search the class loader of the current thread.
If not found, it will search the interpreters of the specifed
page (Page.getLoadedInterpreters()
).
Note: this method won't attach the component to the specified page.
java.lang.ClassNotFoundException
- if the class not foundpublic java.lang.Class resolveImplementationClass(Page page) throws java.lang.ClassNotFoundException
If the implementation class (getImplementation()
)
doesn't have any EL expression, or its EL expresson doesn't
referece to the self variable, the result is the same.
This method is preserved for backward compatibility.
It is better to use resolveImplementationClass(Page, Component)
.
java.lang.ClassNotFoundException
public AnnotationMap getAnnotationMap()
public void applyProperties(Component comp)
It also invokes ComponentDefinition.applyProperties(org.zkoss.zk.ui.Component)
.
Note: custom attributes are not part of ComponentInfo
,
so they won't be applied here.
Note: annotations are applied to the component when a component
is created. So, this method doesn't and need not to copy them.
See also AbstractComponent.AbstractComponent()
.
public java.util.Map evalProperties(java.util.Map propmap, Page owner, Component parent, boolean defIncluded)
ComponentDefinition
(and ComponentInfo
).
propmap
- the map to store the retrieved properties
(String name, Object value).
If null, a HashMap instance is created.owner
- the owner page; used if parent is nullparent
- the parent component (may be null)defIncluded
- whether to call ComponentDefinition.evalProperties(java.util.Map, org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Component)
.public void addAnnotation(java.lang.String annotName, java.util.Map annotAttrs)
annotName
- the annotation name (never null, nor empty).annotAttrs
- a map of attributes, or null if no attribute at all.
The attribute must be in a pair of strings (String name, String value).public void addAnnotation(java.lang.String propName, java.lang.String annotName, java.util.Map annotAttrs)
propName
- the property name (never nul, nor empty).annotName
- the annotation name (never null, nor empty).annotAttrs
- a map of attributes, or null if no attribute at all.
The attribute must be in a pair of strings (String name, String value).public Evaluator getEvaluator()
public ComponentInfo duplicate()
ComposerExt.doBeforeCompose(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.metainfo.ComponentInfo)
to override some properties of the default component info.
Unlike clone()
, the parent-child relation is duplicated
but it is 'virtual'. By virtual we mean
all the children's parent doesn't reference to
the duplicated info (the returned instance).
Rather, they reference to the original info being duplicated.
Since the parent-children relation of the returned info is 'virtual',
you can not call appendChild(org.zkoss.zk.ui.metainfo.TextInfo)
or others to change it.
If you need to change the parent-children relation, use clone()
instead, and then clone the required children.
Notice, we actually copy the values to the returned info so any change to the original one doesn't affect the duplicated info.
clone()
public boolean isEffective(Component comp)
Condition
isEffective
in interface Condition
comp
- used as the self variable. Ignored if null.public boolean isEffective(Page page)
Condition
isEffective
in interface Condition
page
- used as the self variable. Ignored if null.public PageDefinition getPageDefinition()
NodeInfo
getPageDefinition
in class NodeInfo
public NodeInfo getParent()
NodeInfo
getParent
in class NodeInfo
protected EvaluatorRef getEvaluatorRef()
NodeInfo
This method is used only for implementation only.
getEvaluatorRef
in class NodeInfo
public java.lang.Object clone()
getParent()
is null.
The children (@{link #getChildren}) is not cloned, either.
Thus, it is better to use duplicate()
with
ComposerExt.doBeforeCompose(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.metainfo.ComponentInfo)
if you want to override some properties.
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public final void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
java.io.IOException
public final void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readMembers(java.io.ObjectInput)
.
readExternal
in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |