Reputation: 63
I have created a page which is of type cq:page
. I have a component under the jcr:content
node of this page as nt:unstructured
type and points to the component location in apps.
I have hardcoded a component inside this component. Now, I'm unable to access the nodes in the second component. I need to set properties of the nodes (in the second component) using the ResourceResolver — how do I access the nodes in the second component?
Upvotes: 2
Views: 2172
Reputation: 6764
Because you're hard-coding component B inside of component A, you can also statically define its path relative to A.
Presumably, you're using <cq:include>
to embed component B inside of component A.
Two of its possible attributes are the path
and resourceType
. Path in this case is the relative path that the included component will have when created.
So if the JSP for component A contains:
<!--Some component A content here -->
<cq:include path="inner" resourceType="myProject/components/content/componentB"/>
<!-- Some more component A content -->
Any time a node with a resource type of "componentA" is created, it will create a child node with a relative path to component A of "inner" (with a resource type of componentB
).
I.e. if the outer component in your case is at /content/mysite/mypage/jcr:content/componentA
, then the inner component will be at /content/mysite/mypage/jcr:content/componentA/inner
, given the code above.
Upvotes: 1