How to invalidate a document from an event listener
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2017 01:26 PM
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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2017 05:53 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2017 07:30 AM
Thanks Saimir,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2017 08:15 AM
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
