cancel
Showing results for 
Search instead for 
Did you mean: 

How to invalidate a document from an event listener

ioihanguren_
Star Contributor
Star Contributor

Hi,

I have a listener class that implements org.nuxeo.ecm.core.event.EventListener, and I want to invalidate the current document from there. Normally, in a bean, I use to inject NavigationContext, and then use its method to invalidate the document. But I don't know how can I inject NavigationContext to a listener (if it is possible), and I don't know if there is another way to invalidate the current document from there too.

Also, is there a way to inject a bean to a listener? Because that would also work for me.

Thank you very much in advance,

3 REPLIES 3

00000001_
Confirmed Champ
Confirmed Champ

Hi, You can access EventContext, CoreSession, SourceDocument from DocumentEventContext where event is fired ( you can control process of firing event ), but not Navigation Context as listener is executed on background can't access navigation context. You also can get Services instances on listener, as for example Framework.getService(serviceClass), you can contribute your custom services (with your business logic) or use Document Adapter. Thanks

Thanks Saimir,

from listener you can do what you want with document ( invalidate, change life cycle, update properties and sure you can delete it ) all things that you can do in operation chain/seam bean you can do in event listener. It's important to chose right event witch depends on your business. Form more details you can check nuxeo docs https

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.