How to iterate over jcr nodes in specific order? | Community
Skip to main content
jezwn
Level 5
February 13, 2020
Solved

How to iterate over jcr nodes in specific order?

  • February 13, 2020
  • 2 replies
  • 3409 views

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!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by dvnSudheer

@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()

2 replies

dvnSudheerAccepted solution
Level 2
February 13, 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()

joerghoh
Adobe Employee
Adobe Employee
February 14, 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?