Expand my Community achievements bar.

SOLVED

How to iterate over jcr nodes in specific order?

Avatar

Level 6

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!

1 Accepted Solution

Avatar

Correct answer by
Level 3

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

View solution in original post

2 Replies

Avatar

Correct answer by
Level 3

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

Avatar

Employee Advisor

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?