Implicit Objects"

From Documentation
m
m (correct highlight (via JWB))
 
Line 2: Line 2:
  
 
== Overview ==
 
== Overview ==
For scripts embedded in a ZUML page, there are a set of implicit objects that enable developers to access components more efficiently. It's also a mechanism to pass data inter page, application. These objects are available to the Java codes included by the <tt>zscript</tt> element and the attributes for specifying event listeners. They are also available to EL expressions.
+
For scripts embedded in a ZUML page, there are a set of implicit objects that enable developers to access components more efficiently. It's also a mechanism to pass data inter page, application. These objects are available to the Java codes included by the <code>zscript</code> element and the attributes for specifying event listeners. They are also available to EL expressions.
  
For example, <tt>self</tt> is an instance of <javadoc type="interface">org.zkoss.zk.ui.Component</javadoc> to represent the component being processing. In the following example, you could identify the component in an event listener by <tt>self</tt>.
+
For example, <code>self</code> is an instance of <javadoc type="interface">org.zkoss.zk.ui.Component</javadoc> to represent the component being processing. In the following example, you could identify the component in an event listener by <code>self</code>.
  
 
<source lang="xml" >
 
<source lang="xml" >
Line 10: Line 10:
 
</source>
 
</source>
 
   
 
   
Similarly, <tt>event</tt> is the current event being processed by an event listener. Thus, the above statement is equivalent to
+
Similarly, <code>event</code> is the current event being processed by an event listener. Thus, the above statement is equivalent to
  
 
<source lang="xml" >
 
<source lang="xml" >

Latest revision as of 10:36, 19 January 2022

Stop.png This documentation is for an older version of ZK. For the latest one, please click here.


Overview

For scripts embedded in a ZUML page, there are a set of implicit objects that enable developers to access components more efficiently. It's also a mechanism to pass data inter page, application. These objects are available to the Java codes included by the zscript element and the attributes for specifying event listeners. They are also available to EL expressions.

For example, self is an instance of Component to represent the component being processing. In the following example, you could identify the component in an event listener by self.

 <button label="Try" onClick="alert(self.label)"/>

Similarly, event is the current event being processed by an event listener. Thus, the above statement is equivalent to

<button label="Try" onClick="alert(event.target.label)"/>





Last Update : 2022/01/19

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.