Hey everybody, it's been almost three months that I have written a post. This weekend, I finally got some time and a use case which I am going to share with you. We all know workflows play a very important role in the day to day activities of AEM. It is not unheard of that you as a user want to trigger some service/component/scheduler on some of the events in a workflow. To achieve this, it is necessary that we listen to the workflow events in our code and perform our business logic as that event is triggered. In this post, we will see how we can achieve this using an EventHandler (to know how EventHandler works, see this post ). Since AEM has a rich set of APIs, we are fortunate that it has also an API through which we can listen to workflow-related events. Steps: Below are the steps through which we can listen to workflow events - Step #1 Create an Event Handler (WorkflowEventsHandler, in our case) which implements the org.osgi.service.event.EventHandler interfac
We all know that when we add an AEM component to a page, it creates the DOM structure on the pages based upon our HTL file. Sometimes we require id attribute to be set in our div for n number of reasons. If we put id attribute in the HTL file itself then it will become static and if in include that component multiple times on the page, the same id will be repeated for all instance; which is not a neat solution. Wouldn't it be nice if we have a mechanism to generate an id randomly and uniquely for each instance of the component on the page? In this post, we are going to do just that. Hence, without further ado, let's get started - Step #1 Create a component that will have the field for unique id. We are making this id editable as well to give more flexibility to the content authors. Below is the cq:dialog.xml file - <?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling= "http://sling.apache.org/jcr/sling/1.0" xmlns