<?init class="..." [arg0="..."] [arg1="..."] [arg2="..."] [arg3="..."]?>
<?init zscript="..." [arg0="..."] [arg1="..."] [arg2="..."] [arg3="..."]?>
There are two formats. The first format is to specify a class that is used to do the application-specific initialization. The second format is to 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 method will return null, when initializing. To retrieve the current desktop, you could use the org.zkoss.zk.ui.Execution interface.
You could specify any number of the init directive. If you choose the first format, the specified class must implement the org.zkoss.zk.ui.util.Initator 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[].
For more information, refer to the Developer's Reference.