Implicit Objects"

From Documentation
(Created page with '{{ZKDevelopersGuidePageHeader}} *Overview *List of Implicit Objects *[[ZUML_Implicit Object…')
 
m (correct highlight (via JWB))
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{{ZKDevelopersGuidePageHeader}}
 
{{ZKDevelopersGuidePageHeader}}
  
*[[ZUML_Implicit Objects#Overview|Overview]]
+
== Overview ==
*[[ZUML_Implicit Objects#List_of_Implicit_Objects|List of Implicit Objects]]
+
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.
*[[ZUML_Implicit Objects#Information_about_Request_and_Execution|Information about Request and Execution]]
+
 
*[[ZUML_Implicit Objects#Lifecycle_of_page.2C_request.2C_session.2C_application|Lifecycle of page, execution, desktop, session, application]]
+
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>.
*[[ZUML_Implicit Objects#About_xxxScope|About xxxScope]]
+
 
 +
<source lang="xml" >
 +
<button label="Try" onClick="alert(self.label)"/>
 +
</source>
 +
 +
Similarly, <code>event</code> is the current event being processed by an event listener. Thus, the above statement is equivalent to
 +
 
 +
<source lang="xml" >
 +
<button label="Try" onClick="alert(event.target.label)"/>
 +
</source>
 +
 
 +
 
 +
{{ZKDevelopersGuideHeadingToc}}
  
  
 
{{ ZKDevelopersGuidePageFooter}}
 
{{ ZKDevelopersGuidePageFooter}}

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.