Interface Initiator
- All Known Implementing Classes:
Composition,GenericInitiator,ZScriptInitiator
<?init class="MyInit"?>
Once specified, an instance is created and doInit(org.zkoss.zk.ui.Page, java.util.Map<java.lang.String, java.lang.Object>) is called
before the page is evaluated.
If you'd like to intercept other activity, you could implement
InitiatorExt too.
Then, InitiatorExt.doAfterCompose(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Component[]) is called
after all components are created, and before any event is processed.
In additions, InitiatorExt.doFinally() is called
after the page has been evaluated. If an exception occurs, InitiatorExt.doCatch(java.lang.Throwable)
is called.
A typical usage: starting a transaction in doInit, rolling back it
in InitiatorExt.doCatch(java.lang.Throwable) and commit it in InitiatorExt.doFinally()
(if InitiatorExt.doCatch(java.lang.Throwable) is not called).
- Author:
- tomyeh
- See Also:
-
Method Summary
-
Method Details
-
doInit
Does the initializes before the page is evaluated.Note: when it is called,
Page.getDesktop(),Page.getId()andPage.getTitle()all return null, since the page is not initialized yet. To get the current desktop, you have to useExecution.getDesktop()(fromExecutions.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) byPage.setId(java.lang.String),Page.setTitle(java.lang.String)andPage.setStyle(java.lang.String). In additions,Page.getRequestPath()andPage.getAttribute(java.lang.String, int)are all available.- Parameters:
page- the page being evaluatedargs- 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:
Exception
-