Expand my Community achievements bar.

Fetch the list of values for a field

Avatar

Level 1

Hi Team,

  I'm new to the Experience Manager and JCR repository. I have to implement a JCR Query to fetch the values from a content node.

  Example: The content folder under several nodes.

                 /content/folder1/folder2/data1,  /content/folder1/folder2/data2 with some properties inside it.

                 The data under folder2 in json format looks in this way:

{

"sling:resourceType": "xyz/exp-manager",

"jcr:primaryType": "xyz:adobe",

"test": "hi",

"list": {

   "0": {

     "ids": [],

     "sling:resourceType": "xyz/list",

     "jcr:primaryType": "nt:unstructured"

       },

    "jcr:primaryType": "nt:unstructured"

},

"adobe": {

"text1": "hello,

}

}

In this way i have several folder under content. Now I have to implement a query to fetch the id's available under list node in all the folders.

Is this possible to achieve it. Please help in resolving it.

Thanks,

Varun.

2 Replies

Avatar

Level 10

Once you query the list node, you can read the ID property by using syntax to read an Array.

Once you get the node that contains this property - you can get the array by using this JCR API code;

Property references = node.getProperty("id"); 

Value[] values = references.getValues();

String myId = values[0].getString();

Hope this helps...