Expand my Community achievements bar.

SOLVED

Include component in run rime using cq:inlude/sling:inlude does not persist component node in JCR content

Avatar

Level 4

A custom parent component 's JSP has include statement like this  (parentXXX)

<c:if test="${someThing== true}">
                    <sling:include path="childXXXNode" resourceType="apps/xxx/components/childXXX" />               
   </c:if>

Two scenario.

1. if i drag and drop childXXX on the CQ page parsys area, immediately  childXXXNode node would be created under /content/site/page/par/childXXXNode.. that's fine

2.if i include childXXX as stated above in JSP code , then if i go to edit dialog for the child component ,CQ5 throws 404 for childXXXNode.infinity.json since that path has not been created yet but once you save edit dialog , node gets created and then next time CQ5 never throws 404 because JCR Path for child component has been created under page/par/parentXXX node under content..

Now question is : How can we create JCR node for child component  under page/par/parentXXX/ as soon as include statement gets executed very first time?

Thanks Chandra

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Chandra,

In your scenario 2 you don't create this component in the page's parsys, so the include will fail. Why do you want to create the component when it's included? Why do you want to include it at all if it's not present?

Jörg

View solution in original post

2 Replies

Avatar

Correct answer by
Employee Advisor

Chandra,

In your scenario 2 you don't create this component in the page's parsys, so the include will fail. Why do you want to create the component when it's included? Why do you want to include it at all if it's not present?

Jörg

Avatar

Level 4

In Scenario 2,  child component is included in the parent component (baked in page template itself), condition based include is different than non-condition based include of the component .

so what happen when page load gets completed and based on edit dialog configuration on parent component by author, condition meets criteria and child component is displayed but same time if you check JCR, that child node has not been created  , it only gets created when you open child node dialog and click on save.