Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
BrianKasingli
BrianKasingliAccepted solution
Adobe Champion and Community Advisor
Mar 10, 2021 7:00 PM UTC

@karthick1356,

There are two ways.

1. OSGI configuration data in Sightly, where your JavaScript will pickup configuration from there. An example implementation can be found here https://sourcedcode.com/blog/aem/with-htl-pass-data-from-aem-backend-to-javascript

2. OSGI configuration data via Sling Servlet. You can create a servlet that can be utilized by the JavaScript business logic. An Ajax request should be sufficient to obtain the OSGI configuration data.

6 replies

Ankur_Khare
Community Advisor
Community Advisor
Mar 10, 2021 9:37 AM UTC

You need to read in your component html from sling model and keep it in hidden field and then use it in javascript.

Translate
Ankur
Level 4
Mar 11, 2021 10:13 AM UTC
could you please give me a example.
Translate
Kiran_Vedantam
Community Advisor
Community Advisor
Mar 10, 2021 9:52 AM UTC

Hi @karthick1356,

 

To fetch the OSGI Values, first read them in HTML from Java via data attribute and in JS you can initialize the module and access it.

 

Find my related answer here

 

Hope this helps.

 

Thanks,

Kiran Vedantam.

Translate
Level 4
Mar 10, 2021 10:01 AM UTC
Hi KiranVedantam1992, Thanks.
Translate
BrianKasingli
Adobe Champion and Community Advisor
BrianKasingliAdobe Champion and Community AdvisorAccepted solution
Adobe Champion and Community Advisor
Mar 10, 2021 7:00 PM UTC

@karthick1356,

There are two ways.

1. OSGI configuration data in Sightly, where your JavaScript will pickup configuration from there. An example implementation can be found here https://sourcedcode.com/blog/aem/with-htl-pass-data-from-aem-backend-to-javascript

2. OSGI configuration data via Sling Servlet. You can create a servlet that can be utilized by the JavaScript business logic. An Ajax request should be sufficient to obtain the OSGI configuration data.

Translate