Life Cycle Listener"

From Documentation
(Created page with '{{ZKDevelopersReferencePageHeader}} __TOC__ You could have some custom initialization and cleanup when an application, a session, a desktop or an execution is instantiated or …')
 
Line 4: Line 4:
 
   
 
   
 
You could have some custom initialization and cleanup when an application, a session, a desktop or an execution is instantiated or about to being destroyed.
 
You could have some custom initialization and cleanup when an application, a session, a desktop or an execution is instantiated or about to being destroyed.
 +
 +
There are two steps:
 +
#Implements the corresponding interface. For example, <javadoc type="interface">org.zkoss.zk.ui.util.WebAppInit</javadoc> for application's initialization
 +
#Register it in <tt>WEB-INF/zk.xml</tt>, or in Java.
 +
 +
{| border='1px' | width="100%"
 +
! Version !! Date !! Content
 +
|-
 +
| Scope
 +
| Interfaces
 +
| Description
 +
|-
 +
| Application
 +
|
 +
* Init: <javadoc type="interface">org.zkoss.zk.ui.util.WebAppInit</javadoc>
 +
* Cleanup: <javadoc type="interface">org.zkoss.zk.ui.util.WebAppCleanup</javadoc>
 +
|
 +
|}
 +
 +
The registration in <tt>WEB-INF/zk.xml</tt> is the same, no matter what interface you implement:
 +
 +
<source lang="xml">
 +
<listener>
 +
    <listener-class>my.MyImplementation</listener-class>
 +
</listener>
 +
</source>
 +
 +
The registration in Java is done by <javadoc method="addListener(java.lang.Class)">org.zkoss.zk.ui.util.Configuration</javadoc>.
 +
 +
<source lang="java">
 +
webapp.getConfiguration().addListener(my.MyImplementation.class);
 +
</source>
  
 
=Version History=
 
=Version History=

Revision as of 06:33, 2 December 2010


Life Cycle Listener


You could have some custom initialization and cleanup when an application, a session, a desktop or an execution is instantiated or about to being destroyed.

There are two steps:

  1. Implements the corresponding interface. For example, WebAppInit for application's initialization
  2. Register it in WEB-INF/zk.xml, or in Java.
Version Date Content
Scope Interfaces Description
Application

The registration in WEB-INF/zk.xml is the same, no matter what interface you implement:

<listener>
    <listener-class>my.MyImplementation</listener-class>
</listener>

The registration in Java is done by Configuration.addListener(Class).

webapp.getConfiguration().addListener(my.MyImplementation.class);

Version History

Last Update : 2010/12/02


Version Date Content
     



Last Update : 2010/12/02

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