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

How to get a list of components which are present on a page

Avatar

Avatar
Validate 1
Level 2
ssharma48
Level 2

Likes

2 likes

Total Posts

6 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Boost 1
View profile

Avatar
Validate 1
Level 2
ssharma48
Level 2

Likes

2 likes

Total Posts

6 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Boost 1
View profile
ssharma48
Level 2

09-04-2019

Hi all,

We have a requirement where need to extract the list of components which are present on the page at Runtime via a Page Model. If anyone has implemented the same please share the sample.

Thank you.

Shikha

Replies

Avatar

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
Gaurav-Behl
MVP

09-04-2019

You could follow the OOB code for "Content Tree" implementation in author or otherwise, get the page node and iterate over each node and find "sling:resourceType"

You'd have to customize based on your use case either client side or server side.

1729563_pastedImage_0.png

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,272 likes

Total Posts

3,151 posts

Correct Reply

887 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,272 likes

Total Posts

3,151 posts

Correct Reply

887 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

10-04-2019

Hi,

You can write JCR Queries(XPATH, SQL2 or QueryBuilder) to find out node with sling:resourceType under Page:content node of a page.