Package org.zkoss.zk.ui.util
Class GenericInitiator
- java.lang.Object
-
- org.zkoss.zk.ui.util.GenericInitiator
-
- All Implemented Interfaces:
Initiator
,InitiatorExt
public abstract class GenericInitiator extends java.lang.Object implements Initiator, InitiatorExt
A skeletal implementation that provides does-nothing for all methods, such that the deriving class needs only to implement the required method.- Since:
- 5.0.5
- Author:
- tomyeh
-
-
Constructor Summary
Constructors Constructor Description GenericInitiator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doAfterCompose(Page page)
It is used only for backward compatibility.void
doAfterCompose(Page page, Component[] comps)
Called after all components are created (a.k.a., composed), and before any event is processed.boolean
doCatch(java.lang.Throwable ex)
Does nothing but returns false so the exception will be thrown.void
doFinally()
Do the cleanup after the page has been evaluated.void
doInit(Page page, java.util.Map<java.lang.String,java.lang.Object> args)
Does the initializes before the page is evaluated.
-
-
-
Method Detail
-
doInit
public void doInit(Page page, java.util.Map<java.lang.String,java.lang.Object> 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()
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.- Specified by:
doInit
in interfaceInitiator
- 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:
java.lang.Exception
-
doAfterCompose
public void doAfterCompose(Page page, Component[] comps) throws java.lang.Exception
Description copied from interface:InitiatorExt
Called after all components are created (a.k.a., composed), and before any event is processed.It won't be called if an un-caught exception occurs when creating components.
- Specified by:
doAfterCompose
in interfaceInitiatorExt
- Parameters:
page
- the page that new components are attached to. It is the same asInitiator.doInit(org.zkoss.zk.ui.Page, java.util.Map<java.lang.String, java.lang.Object>)
's page argument.comps
- the root components being created (never null, but the length might be zero). Note: It is not necessary the same asPage.getRoots()
, since this method might be called thruExecutions.createComponents(java.lang.String, org.zkoss.zk.ui.Component, java.util.Map<?, ?>)
.- Throws:
java.lang.Exception
-
doAfterCompose
public void doAfterCompose(Page page)
It is used only for backward compatibility. Don't use it.
-
doCatch
public boolean doCatch(java.lang.Throwable ex) throws java.lang.Exception
Does nothing but returns false so the exception will be thrown.- Specified by:
doCatch
in interfaceInitiatorExt
- 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
- Throws:
java.lang.Exception
-
doFinally
public void doFinally() throws java.lang.Exception
Description copied from interface:InitiatorExt
Do the cleanup after the page has been evaluated. It won't be called ifInitiator.doInit(org.zkoss.zk.ui.Page, java.util.Map<java.lang.String, java.lang.Object>)
throws an exception. However,it is always called no matter whetherInitiatorExt.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 interfaceInitiatorExt
- Throws:
java.lang.Exception
-
-