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 iterate over jcr nodes in specific order?

Avatar

Avatar
Contributor
Level 2
jezwn
Level 2

Likes

9 likes

Total Posts

69 posts

Correct Reply

2 solutions
Top badges earned
Contributor
Shape 1
Springboard
Establish
Validate 1
View profile

Avatar
Contributor
Level 2
jezwn
Level 2

Likes

9 likes

Total Posts

69 posts

Correct Reply

2 solutions
Top badges earned
Contributor
Shape 1
Springboard
Establish
Validate 1
View profile
jezwn
Level 2

12-02-2020

I was working around with the iterator to list and traverse over child nodes and I'm getting this anomalous behavior where the iterator lists the nodes in different order each time. I need to iterate over nodes as it's present in the crx/de. Is there a way it could be done, to control the order of listing!

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Give Back 5
Level 2
dvnSudheer
Level 2

Likes

13 likes

Total Posts

13 posts

Correct Reply

3 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Boost 5
Boost 3
View profile

Avatar
Give Back 5
Level 2
dvnSudheer
Level 2

Likes

13 likes

Total Posts

13 posts

Correct Reply

3 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Boost 5
Boost 3
View profile
dvnSudheer
Level 2

13-02-2020

@jezwn, Could you please provide more information on what kind of nodes are you referring to and what is the API you are using to get the children.

 

Ideally if you use the page API, it will give the same order as it is created for the child pages, if you would like to have a different order, you can always change it from the sites console and the API will return the pages in the new order

API: page.listChildren()

Answers (1)

Answers (1)

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,087 likes

Total Posts

3,121 posts

Correct Reply

1,063 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,087 likes

Total Posts

3,121 posts

Correct Reply

1,063 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

14-02-2020

Hi,

 

in JCR nodes can be of 2 types: ordered or unordered. In the case of ordered nodes child nodes are always returned in the same order. In the case of unordered nodes child nodes the order is not guaranteed.

Most types are ordered, especially when dealing in areas where order matters. In case it does not, unordered nodes can be used which can bring a performance benefit.

 

What node types are you iterating?