Skip to main content
Level 2
Feb 16, 2024 11:38 AM UTC
Solved

Aem dialog drop-down option from api in 6.5

Hi Team, 

We want to create a dilog field where we can load drop-down option of api response when dilog is opened can we try this from datasourse or data source call backend each time when opened?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Imran Khan
Imran KhanAccepted solution
Community Advisor
Feb 21, 2024 11:45 AM UTC

6 replies

AsifChowdhury
Community Advisor
Community Advisor
Feb 16, 2024 11:54 AM UTC

Hi @ashishm85330433 

 

You can create a clientlib with some custom js like this:

 

(function (document, $) { "use strict"; $(document).on("foundation-contentloaded", function (e) { // do your custom code here }); })(document, Granite.$);

 

Then call the clientlib in the component dialog xml using "extraClientlibs" property. This JS will called when you open the dialog.

 

NB. There are some other event available also like you want to do some thing on submit of a dialog.

 

Thanks.

Translate
Imran Khan
Community Advisor
Community Advisor
Feb 16, 2024 12:04 PM UTC

@ashishm85330433 DataSource is the best suggested approach to load dropdown options as we can make secure API call to third party system. Its easy to maintain the tokens and other API configuration in backend approach.

We can go ahead with @asifchowdhury approach, if the 3rd party is public and doesn't require any token to access the same. In this we may not require whitelisting to access API.

Translate
Level 2
Feb 16, 2024 7:34 PM UTC

Thanks @imran__khan but how datasourse will call servlet.

Translate
Imran Khan
Community Advisor
Imran KhanCommunity AdvisorAccepted solution
Community Advisor
Feb 21, 2024 11:45 AM UTC
arunpatidar
Community Advisor
Community Advisor
Feb 16, 2024 1:34 PM UTC
kautuk_sahni
Level 9
Feb 21, 2024 11:38 AM UTC

@ashishm85330433 Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Translate
Kautuk Sahni