In custom Grails applications that use Weceem plugin you may need to perform actions when certain events occur on content.
To do this you register a listener with the WcmEventService and implement any of the event notification methods you require.
First, you inject the WcmEventService using Grails dependency injection, or obtain it via the Spring ApplicationContext, and then you call the "addListener" method:
class MyService implements InitializingBean { def wcmEventService void afterPropertiesSet() { wcmEventService.addListener(this) } void contentDidGetUpdated(WcmContent node) { log.info "Look! Content ${node.title} was updated" } }
The list of available events is defined in the WeceemEvents class, which uses an optional event callback method mechanism. You just implement the methods you need, using the signature defined in the WeceemEvents class.
There is a separate event interface called WeceemDomainEvents for developers that supply custom content types, for which you do not need to register as a lister - they are called as part of the regular lifecycle.