I have one simple component called testcomponent under apps/test/components/testcomponent
Now I want to include content fragment component inside the testcomponent.jsp..How can I include my content fragment component in my JSP.
Thanks in advance
Solved! Go to Solution.
First of all I would suggest you to please use HTL instead of JSP.
Answering your question : You can include HTML file in your JSP (<cq:include script="include.html"/> ) and write all code using sightly. You can use cq:template to include CF component inside your component. It will add node when you add component in Page. In HTL, you can use data-sly-resource for CF component.
Refer We-Retail Code : /apps/weretail/components/structure/footer/cq:template & /apps/weretail/components/structure/footer/footer.html
The below doc gives you all the syntax to include tag libraries in JSP.
The Granite, CQ, and Sling tag libraries give you access to specific functions for use in the JSP script of your templates and components.
The <cq:include> the tag includes a resource on the current page. I think that would suffice your content fragment use case too.
Hi @haritha6 ,
It seems like you are trying to implement Content Fragment into your component.
for that, try to implement Content Fragment component from core components into your project by
sling:resourceSuperType = /core/wcm/components/contentfragment/v1/contentfragment.
change jsp to HTML & write your custom HTL as required.
OR if your requirement is to include a Content Fragment into your existing jsp component, then use <cq:include> as others said.