Cq5 get parent properties of node

I have a component hierarchy parsys -> parentcomp -> childcomp

parentcompnode has some properties. I am trying to access the parent properties parentcompat the level childcomp.

I am not sure how to do this.

Any idea how to get the parent properties of a node. I know the following code, gives me a path having a parent node as one of the selectors. But not sure how to get to a precisely defined node and read these properties.

<%= currentNode.getPath() %>

Thank you Sri

+4
source share
2 answers

There are many ways to achieve this.

  • Using the resource API where an object resourceis accessible through inclusionglobal.jsp

    ValueMap parentProps = resource.getParent().getValueMap(); //in latest versions of AEM ValueMap parentProps = resource.getParent().adaptTo(ValueMap.class); //older versions

  • Node API currentNode.

    PropertyIterator propertyIterator = currentNode.getParent().getProperties()

Resource API , .

+6

currentNode Node JCR API.

Node - getParent, JCR Node node.

, currentNode.getParent().getProperties() parentcomp Node. , AEM, , , jcr:content. CRXDE.

, getProperty.

+4

Source: https://habr.com/ru/post/1622005/


All Articles