I have two components, C1 and C2. C2 can contain C1 components.
C1 has a jsp file called "c1.directive.jsp" which outputs some xml-like data:
<c1-element></c1-element>
C2 has a jsp file called "c2.directive.jsp" which outputs some xml-like data and also tries to output the directive.jsp of its C1 children:
<c2-element> // for each child, get childpath and append "directive" selector <sling:include path="<%=childpath%>" </c2-element>
When I request "[server]/content/.../c1.directive", I get the result I expect:
<c1-element></c1-element>
However, when I request "[server]/content/.../c2.directive", I get this:
<c2-element> <div class="parbase c1"> <c1-element></c1-element> <script type="text/javascript"> CQ.WCM.edit({"path":"/content/.../c1","dialog":"/apps/.../c1/dialog","type":"../c1","csp":"c1|page/menu|parbase/c1|parbase"}); </script> </div> </c2-element>
Why do I get the correct response when I request the C1 directive directly, but not when the same path is sling:include'd in another jsp? Why do I get the <div> and <script> tags and how can I prevent this?
Solved! Go to Solution.
Views
Replies
Total Likes
So in the end, this is what I did and it worked for me:
(1) I changed my request to be: [server]/content/.../c2.directive?wcmmode=disabled
That removed the <script> tags.
(2) Then, to remove the CQ decoration tags, I created a jsp containing the following:
if (WCMMode.fromRequest(request) != WCMMode.EDIT && WCMMode.fromRequest(request) != WCMMode.DESIGN) { IncludeOptions.getOptions(request, true).forceSameContext(Boolean.TRUE).setDecorationTagName(""); }
and included that jsp in my directive.jsps.
Views
Replies
Total Likes
This question comes up from time to time. When nesting components in CQ - there are some restrictions around listeners, etc. See this doc topic:
http://docs.adobe.com/docs/en/cq/5-6-1/developing/components.html
Views
Replies
Total Likes
Hi,
You are getting a correct response. Take a printout+ attach to desk or Keep [1] handy it will solve many issue.
[1] http://dev.day.com/content/ddc/blog/2008/07/cheatsheet/_jcr_content/images/cheatsheet/front.png
[2] http://training.adobe.com/training/courses/cq5-developer-training.html
Thanks,
Sham
Views
Replies
Total Likes
I think you misunderstood me. The output of my component.directive.jsps have nothing to do with widgets or component development per se.
At it's very basic, my question is: (1) why does sling resolve my .directive selector differently when the path is included in another jsp versus when I request the same path directly? and (2) how can I fix this?
Views
Replies
Total Likes
So in the end, this is what I did and it worked for me:
(1) I changed my request to be: [server]/content/.../c2.directive?wcmmode=disabled
That removed the <script> tags.
(2) Then, to remove the CQ decoration tags, I created a jsp containing the following:
if (WCMMode.fromRequest(request) != WCMMode.EDIT && WCMMode.fromRequest(request) != WCMMode.DESIGN) { IncludeOptions.getOptions(request, true).forceSameContext(Boolean.TRUE).setDecorationTagName(""); }
and included that jsp in my directive.jsps.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies