Include component in run rime using cq:inlude/sling:inlude does not persist component node in JCR content | Community
Skip to main content
Chandra_gupta
Level 4
October 16, 2015
Solved

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

  • October 16, 2015
  • 2 replies
  • 1079 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by joerghoh

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

2 replies

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

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

Chandra_gupta
Level 4
October 16, 2015

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.