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
BedrockMission!

Learn More

View all

Sign in to view all badges

osgi config to javascript

Avatar

Avatar
Validate 1
Level 1
karthick1356
Level 1

Likes

0 likes

Total Posts

14 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
karthick1356
Level 1

Likes

0 likes

Total Posts

14 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
karthick1356
Level 1

10-03-2021

How to Fetch OSGI configurations value in JavaScript ?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

644 likes

Total Posts

605 posts

Correct Reply

239 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

644 likes

Total Posts

605 posts

Correct Reply

239 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
BrianKasingli
MVP

10-03-2021

@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.

Answers (2)

Answers (2)

Avatar

Avatar
Springboard
Level 7
KiranVedantam1992
Level 7

Likes

190 likes

Total Posts

199 posts

Correct Reply

60 solutions
Top badges earned
Springboard
Give Back 5
Ignite 1
Affirm 50
Validate 1
View profile

Avatar
Springboard
Level 7
KiranVedantam1992
Level 7

Likes

190 likes

Total Posts

199 posts

Correct Reply

60 solutions
Top badges earned
Springboard
Give Back 5
Ignite 1
Affirm 50
Validate 1
View profile
KiranVedantam1992
Level 7

10-03-2021

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.

Avatar

Avatar
Ignite 1
MVP
Ankur_Khare
MVP

Likes

159 likes

Total Posts

370 posts

Correct Reply

58 solutions
Top badges earned
Ignite 1
Validate 10
Validate 1
Give Back 50
Give Back 5
View profile

Avatar
Ignite 1
MVP
Ankur_Khare
MVP

Likes

159 likes

Total Posts

370 posts

Correct Reply

58 solutions
Top badges earned
Ignite 1
Validate 10
Validate 1
Give Back 50
Give Back 5
View profile
Ankur_Khare
MVP

10-03-2021

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