Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

Listeners

Avatar

Level 9

Hi All,

I was trying to understand what exactly are listeners.

Came across the article in link http://experience-aem.blogspot.in/2014/03/aem-cq-56-sample-editconfig-listener-for-drag-drop.html. But could not understand much.

If some one could provide a detailed explanation, it would be helpful.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Basically, listeners are in simple words nothing but an activity or a service that will be watching for an event and triggers it. As scott mentioned listeners can be used for xtype (ex: Do something on selecting a selection xtype), or a JCR events like NODE_CREATE, NODE_UPDATE etc...

You can refer those articles to get indepth details about the same.

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Basically, listeners are in simple words nothing but an activity or a service that will be watching for an event and triggers it. As scott mentioned listeners can be used for xtype (ex: Do something on selecting a selection xtype), or a JCR events like NODE_CREATE, NODE_UPDATE etc...

You can refer those articles to get indepth details about the same.

Avatar

Level 10

In AEM - there are different type of listeners (aka -- event handlers). Knowing how to work with the different types is important. 

You can code listeners at the component level. That is - when creating a custom xtype - and someone selects a value from a drop-down control - an event handler is fired off. This is just a JS method. For example: 

listeners: {
                selectionchanged: {
                    scope:this,
                    fn: this.updateHidden
                }
            },
// called when a selection in the drop-down is made

updateHidden: function() {
    var val1 = this.linkType.getValue();
    this.linkText.setValue(val1);
}

To learn how to work with event handlers for components - see this AEM community article: 

https://helpx.adobe.com/experience-manager/using/dynamically-updating-aem-custom-xtype.html

2. A second type of event handler in AEM occurs at the JCR level - you can code JCR event handles. WHen a node in the JCR is changed - an event handler is fired off. To learn how to write these types of event handlers -- see this community article: 

https://helpx.adobe.com/experience-manager/using/events.html

3. Some parts of AEM - like the DAM - also have handlers. You can write an AEM DAM Handler. See: 

https://helpx.adobe.com/experience-manager/using/damhandler.html

or replication events:

https://helpx.adobe.com/experience-manager/using/replication_events.html

4. Of course - you can use standard HTML/JS events in AEM too. Like when someone clicks a button on a form - an AJAX request is send to the server. See: 

https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now