Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How to dynamically populate AEM page property dialog ?

Avatar

Level 9

  I would like to create a new custom tab in the AEM page properties. The process of creating a page property is straightforward, but inside the custom tab, I want to make a call to an external system and get a json response, so that I can build a dialog (with text fields and path fields). To get the json response, I created a servlet, but I want to call this servlet each time a property dialog appears and populate its fields. Would it be possible to do that? Should I update dialog.xml for this or can I manage it directly at the page level (/content)?  

 

Please share me some best practices on this use cases.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@Mario248 :

 

You want to make a servlet call when you opened a component dialog right . So that you can write a JS as below inside you can make ajax call to your servlet.

 

(function ($, $document) {
"use strict";
$document.on("dialog-ready", function() {
alert('Its coming here on dialog open');
});
})($, $(document));

 

But the above code will get invoked for every component.

 

As explained in the below link, you can use extraclientlibs, which will invoke the targeted client library that is configured.

 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/hi-all-i-was-trying-to-cal...

 

Thanks,

Siva

 

 

 

 

Thanks,
Siva

View solution in original post

4 Replies

Avatar

Community Advisor

@Mario248 :

 

You can follow the below link.

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/hi-all-i-was-trying-to-cal...

 

Please do check this. If required any additional help let know

 

Thanks 

Siva

Thanks,
Siva

Avatar

Level 9

The link you provided explain how to to create a clientlibs for custom component. It is not related to my use case

Avatar

Correct answer by
Community Advisor

@Mario248 :

 

You want to make a servlet call when you opened a component dialog right . So that you can write a JS as below inside you can make ajax call to your servlet.

 

(function ($, $document) {
"use strict";
$document.on("dialog-ready", function() {
alert('Its coming here on dialog open');
});
})($, $(document));

 

But the above code will get invoked for every component.

 

As explained in the below link, you can use extraclientlibs, which will invoke the targeted client library that is configured.

 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/hi-all-i-was-trying-to-cal...

 

Thanks,

Siva

 

 

 

 

Thanks,
Siva

Avatar

Community Advisor

@Mario248 You can write data source servlets as given in the example link below and make use of it in the dialog to populate the values dynamically. In the servlet you need to make the call to external system and return the values to dialog.

http://www.sgaemsolutions.com/2019/01/dynamically-populate-drop-down-values.html