org.zkoss.zk.ui.impl
Class ZScriptInitiator

java.lang.Object
  extended by org.zkoss.zk.ui.impl.ZScriptInitiator
All Implemented Interfaces:
Initiator

public class ZScriptInitiator
extends java.lang.Object
implements Initiator

An initiator used to evaluate a zscript file. Used internally by Parser to evaluate the init directive with zscript:
<?init zscript="xxx"?>

Author:
tomyeh

Constructor Summary
ZScriptInitiator(ZScript script)
           
 
Method Summary
 void doAfterCompose(Page page)
          Called after all components are created (aka., composed), and before any event is processed.
 boolean doCatch(java.lang.Throwable ex)
          Called when an exception occurs during the evaluation of the page.
 void doFinally()
          Do the cleanup after the page has been evaluated.
 void doInit(Page page, java.util.Map args)
          Does the initializes before the page is evaluated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZScriptInitiator

public ZScriptInitiator(ZScript script)
Method Detail

doInit

public void doInit(Page page,
                   java.util.Map args)
            throws java.lang.Exception
Description copied from interface: Initiator
Does the initializes before the page is evaluated.

Note: when it is called, Page.getDesktop(), Page.getId() and Page.getTitle() all return null, since the page is not initialized yet. To get the current desktop, you have to use Execution.getDesktop() (from Executions.getCurrent()) instead. On the other hand, you can set the page's ID, title or style in this method (to override the declarations in the page definition) by Page.setId(java.lang.String), Page.setTitle(java.lang.String) and Page.setStyle(java.lang.String). In additions, Page.getRequestPath() and Page.getAttribute(java.lang.String, int) are all available.

Specified by:
doInit in interface Initiator
Parameters:
page - the page being evaluated
args - a map of arguments. Prior to 3.6.2, it is an array. To upgrade, use args.get("arg0") instead of args[0], args.get("arg1") instead of args[1] and so on. Of course, it is better to have a more meaningful name for each argument. If no argument is specified, args is an empty map (never null).
Throws:
java.lang.Exception

doAfterCompose

public void doAfterCompose(Page page)
                    throws java.lang.Exception
Description copied from interface: Initiator
Called after all components are created (aka., composed), and before any event is processed.

Note: if InitiatorExt is also implemented, this method won't be called. Rather, InitiatorExt.doAfterCompose(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Component[]) will be called instead.

For example, the data-binding managers could process the binding at this callback.

It won't be called if an un-caught exception occurs when creating components.

Specified by:
doAfterCompose in interface Initiator
Parameters:
page - the page that new components are attached to. It is the same as Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map)'s page argument.
Throws:
java.lang.Exception

doCatch

public boolean doCatch(java.lang.Throwable ex)
Description copied from interface: Initiator
Called when an exception occurs during the evaluation of the page.

If you don't want to handle the exception, simply returns false. boolean doCatch(Throwable ex) {return false;}

An exception thrown in this method is simply logged. It has no effect on the execution. If you want to ignore the exception, just return true.

Notice: this method won't be called if the exception occurs in Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map).

Specified by:
doCatch in interface Initiator
Parameters:
ex - the exception being thrown
Returns:
whether to ignore the exception. If false is returned, the exception will be re-thrown. Note: once an initiator's doCatch returns true, the exception will be ignored and it means doCatch of the following initiators won't be called. Prior to ZK 3.0.0, void is returned and it means always re-thrown

doFinally

public void doFinally()
Description copied from interface: Initiator
Do the cleanup after the page has been evaluated. It won't be called if Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map) throws an exception. However,it is always called no matter whether Initiator.doCatch(java.lang.Throwable) is called.

An exception thrown in this method is simply logged. It has no effect on the execution.

Specified by:
doFinally in interface Initiator


Copyright © 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo