Fetch the list of values for a field

Avatar

Avatar

appleb75315648

Avatar

appleb75315648

appleb75315648

05-06-2018

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.

Replies

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

05-06-2018

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...

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

05-06-2018

As you are new to AEM - read this article on how to use QueryBuilder API -- Adobe Experience Manager Help | Creating Adobe Experience Manager OSGi bundles that use the Query Bu...