I have a container then layout then config then column then list I want to get those list property but node name changing again and again How can I extract the List name and there properties values without using name.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @rohankalra ,
Try this,
Resource childResource = resourceResolver.getResource(child.getPath()); Node childNode = childResource.adaptTo(Node.class); Node jcrContent = childNode.getNode("jcr:content"); NodeIterator childrenNodes = jcrContent.getNodes(); while(childrenNodes.hasNext()){ Node next = childrenNodes.nextNode(); String resourceType = next.getProperty("sling:resourceType").getString(); if(resourceType.equals("your/custom/resource/property/path")) {
properties = childResource.adaptTo(ValueMap.class);
String propertyOne = properties.get("propertyOne", (String) null);
} }
@rohankalra can you please share sample node structure how it's getting stored in crx ?
You can update your logic to use regex for checking the node name. For example it will always be in these format
list / list_NNNNNNNN_ / list_NNNNNNNN
Else you can go ahead with search based approach. You can write a query to fetch all list components based on sling:resourceType property.
Hi @rohankalra ,
Try this,
Resource childResource = resourceResolver.getResource(child.getPath()); Node childNode = childResource.adaptTo(Node.class); Node jcrContent = childNode.getNode("jcr:content"); NodeIterator childrenNodes = jcrContent.getNodes(); while(childrenNodes.hasNext()){ Node next = childrenNodes.nextNode(); String resourceType = next.getProperty("sling:resourceType").getString(); if(resourceType.equals("your/custom/resource/property/path")) {
properties = childResource.adaptTo(ValueMap.class);
String propertyOne = properties.get("propertyOne", (String) null);
} }