ZK Directive: init"

From Documentation
m (Created page with '{{ZKDevelopersGuidePageHeader}} <source lang="xml" > <?init class="..." [arg0="..."] [arg1="..."] [arg2="..."] [arg3="..."]?> <?init zscript="..."?> </source> There are two app…')
 
m
Line 10: Line 10:
 
* Specify a <tt>zscript</tt> file to do the application-specific initialization.
 
* Specify a <tt>zscript</tt> file to do the application-specific initialization.
  
The initialization takes place before the page is evaluated and attached to a desktop. Thus, the <tt>getDesktop</tt>, <tt>getId</tt> and <tt>getTitle</tt> methods will return null, when initializing. To retrieve the current desktop, you could use the <tt>org.zkoss.zk.ui.Execution</tt> interface.
+
The initialization takes place before the page is evaluated and attached to a desktop. Thus, the <tt>getDesktop</tt>, <tt>getId</tt> and <tt>getTitle</tt> methods will return null, when initializing. To retrieve the current desktop, you could use the <<javadoc type="interface">>org.zkoss.zk.ui.Execution</javadoc> interface.
  
You could specify any number of the <tt>init</tt> directive. If you choose the first format, the specified class must implement the <tt>org.zkoss.zk.ui.util.Initator</tt> interface. Once specified, an instance of the class is constructed and its <tt>doInit</tt> method is called, before the page is evaluated.
+
You could specify any number of the <tt>init</tt> directive. If you choose the first format, the specified class must implement the <<javadoc type="interface"></javadoc>>org.zkoss.zk.ui.util.Initator</javadoc> interface. Once specified, an instance of the class is constructed and its <tt>doInit</tt> method is called, before the page is evaluated.
  
 
In addition, the <tt>doFinally</tt> method is called, after the page has been evaluated. The <tt>doCatch</tt> method is called if an exception occurs. Thus, this directive is not limited to initialization. You could use it for cleanup and error handling.
 
In addition, the <tt>doFinally</tt> method is called, after the page has been evaluated. The <tt>doCatch</tt> method is called if an exception occurs. Thus, this directive is not limited to initialization. You could use it for cleanup and error handling.

Revision as of 03:07, 16 July 2010

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


<?init class="..." [arg0="..."] [arg1="..."] [arg2="..."] [arg3="..."]?>
<?init zscript="..."?>

There are two approaches:

  • Specify a class to do the application-specific initialization.
  • Specify a zscript file to do the application-specific initialization.

The initialization takes place before the page is evaluated and attached to a desktop. Thus, the getDesktop, getId and getTitle methods will return null, when initializing. To retrieve the current desktop, you could use the <Execution interface.

You could specify any number of the init directive. If you choose the first format, the specified class must implement the <[Javadoc Error! Input format should be org.zkoss.package.name.ClassName]>org.zkoss.zk.ui.util.Initator</javadoc> interface. Once specified, an instance of the class is constructed and its doInit method is called, before the page is evaluated.

In addition, the doFinally method is called, after the page has been evaluated. The doCatch method is called if an exception occurs. Thus, this directive is not limited to initialization. You could use it for cleanup and error handling.

If you choose the second format, the zscript file is evaluated and the arguments (arg0, arg1,...) will be passed as a variable called args whose type is Object[].

Since 3.6.2, you can use any (readable) name instead of arg0 and so on. For example,

<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" root="./abc"?>

For more information, refer to the Developer's Reference.



Last Update : 2010/07/16

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