1
votes

I tried to include a component in another component using following code

<%
String fakePath = resource.getPath() + "/nav-tabs";
%>
<cq:include path="<%=fakePath%>" resourceType="ven/components/navMenu"/>

When I open the site page and tried to edit the component to author data, following error is coming in the browser console and not able to see the component dialog.

widgets.js:3318 GET http://localhost:4502/content/ven/global/en/testPage/jcr:content/nav-tabs.infinity.json?_dc=1481236797569 404 (Not Found)

I do not see any resource created below the content tree too.

Could any one shed some light on this?

Thanks, Sri

1

1 Answers

1
votes

It looks like you placing this component directly on the page, because resource.getPath() returns http://localhost:4502/content/ven/global/en/testPage/jcr:content in your case. You can use page templates to create initial content when creating the page.

For components you can use cq:template resource:

Just place cq:template resource beneath your component. As soon you add a new component it should copy the content of it into your resource (similar to page templates)

In your case: _cq_template.xml :

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
      jcr:primaryType="nt:unstructured">
    <nav-tabs
        jcr:primaryType="nt:unstructured"
        sling:resourceType="ven/components/navMenu"/>
</jcr:root>