[opencms-dev] OpenCMS 6 Newsletter module

Sebastian Himberger sebastian.himberger at gmx.de
Tue Jul 5 16:40:02 CEST 2005


Hi,

in the module screen you can define a class wich implements the 
I_CmsModuleAction interface. This Class can be used to register an 
EventListener to the OpenCms system (in Fact the  I_CmsModuleAction is 
derived from the I_CmsEventListener so it can act as a Listener itself). 
During the OpenCms startup the initialize-method of the 
ModuleAction-Object is called. There you can register the Object as an 
EventListener.

e.g: org.opencms.main.A_OpenCms.addCmsEventListener(this) // example 
taken from the Javadocs

Then you will be notified the various events using the Method 
"cmsEvent(CmsEvent event)". There are several event types wich are 
listed in the OpenCms API. You just have to act if an appropiate Event 
happens. E.g:

// Example from the javadocs
public void cmsEvent(com.opencms.flex.CmsEvent event) {
     switch (event.getType()) {
         case com.opencms.flex.I_CmsEventListener.EVENT_PUBLISH_PROJECT:
         case com.opencms.flex.I_CmsEventListener.EVENT_CLEAR_CACHES:
             // do something
             break;
         case com.opencms.flex.I_CmsEventListener.EVENT_LOGIN_USER:
            // do something else
             break;
         }
 }

HTH

Sebastian




<http://synyx.de/api/opencms6b3/org/opencms/main/I_CmsEventListener.html>



More information about the opencms-dev mailing list