Attributes"
m |
Robertwenzel (talk | contribs) m |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{ZUMLReferencePageHeader}} | {{ZUMLReferencePageHeader}} | ||
− | Each attribute, except special attributes like <code>if</code> and <code>forEach</code>, represents a value that | + | Each attribute, except special attributes like <code>if</code> and <code>forEach</code>, represents a value that should be assigned to a property of a component after it is created. For example, when an attribute, say, <code>foo</code>, is specified, ZK Loader will assume there is a method called <code>setFoo</code> that accepts a single argument. If there are multiple methods with the same name, ZK Loader will use the one that matches the argument most (in term of the argument's class). |
For example, suppose <code>${foo}</code> is evaluated to an integer in the following example, ZK Loader will invoke <javadoc method="setMode(int)">org.zkoss.zul.Window</javadoc>, rather than <javadoc method="setMode(java.lang.String)">org.zkoss.zul.Window</javadoc>. | For example, suppose <code>${foo}</code> is evaluated to an integer in the following example, ZK Loader will invoke <javadoc method="setMode(int)">org.zkoss.zul.Window</javadoc>, rather than <javadoc method="setMode(java.lang.String)">org.zkoss.zul.Window</javadoc>. | ||
Line 18: | Line 18: | ||
</source> | </source> | ||
− | There are several ways to associate Java objects with EL expressions<ref>For introductory, please refer to [[ZK_Developer's Reference/UI Composing/ZUML/ | + | There are several ways to associate Java objects with EL expressions<ref>For introductory, please refer to [[ZK_Developer's Reference/UI Composing/ZUML/EL Expressions|ZK Developer's Reference]].</ref>. |
# Implement a variable resolver (<javadoc type="interface">org.zkoss.xel.VariableResolver</javadoc>) and specify it with the [[ZUML Reference/ZUML/Processing Instructions/variable-resolver|variable-resolver]] directive. | # Implement a variable resolver (<javadoc type="interface">org.zkoss.xel.VariableResolver</javadoc>) and specify it with the [[ZUML Reference/ZUML/Processing Instructions/variable-resolver|variable-resolver]] directive. | ||
# Return the object in a static method and specify it in [[ZUML Reference/ZUML/Processing Instructions/xel-method|xel-method]] | # Return the object in a static method and specify it in [[ZUML Reference/ZUML/Processing Instructions/xel-method|xel-method]] |
Latest revision as of 02:31, 1 August 2021
Each attribute, except special attributes like if
and forEach
, represents a value that should be assigned to a property of a component after it is created. For example, when an attribute, say, foo
, is specified, ZK Loader will assume there is a method called setFoo
that accepts a single argument. If there are multiple methods with the same name, ZK Loader will use the one that matches the argument most (in term of the argument's class).
For example, suppose ${foo}
is evaluated to an integer in the following example, ZK Loader will invoke Window.setMode(int), rather than Window.setMode(String).
<window mode="${foo}">
...
The values of attributes usually consist of EL expressions. For example,
<listbox forEach="${matrix}">
<listitem label="${forEachStatus.previous.each.label}: ${each}" forEach=${each.items}/> <!-- nested-->
</listbox>
There are several ways to associate Java objects with EL expressions[1].
- Implement a variable resolver (VariableResolver) and specify it with the variable-resolver directive.
- Return the object in a static method and specify it in xel-method
- Declare multiple static methods in a taglib and declare it in taglib
- Construct them in zscript
In the following sections, we will discuss the special attributes one-by-one.
- ↑ For introductory, please refer to ZK Developer's Reference.