Expand my Community achievements bar.

How to get the Node order in JCR query?

Avatar

Level 10

Hi i just wanted to retrieve all nodes in the order that i see in siteadmin. How can i achive that?

3 Replies

Avatar

Level 9

If you are using Resource API to get the nodes in order, you can't get that. The node iterator returns nodes the way they are in the repository.

The Query could be a better option.

Jitendra

Avatar

Level 10

I think i confused you, actually i want to get the repository order in query.

root-
    --child1
    -- child2
    -- child3

Now I want order as 1,2,3 in query not in node iteration.

Avatar

Level 10

use root node of type sling:OrderedNode so when you list the child nodes under root, you get the order in which the nodes are created (1,2,3)