resource
currentNode
currentPageresource.getPath() is the node that has sling:resourceType (usually /foo/bar/jcr:content)
currentNode.getPath() is the node that has sling:resourceType
currentPage.getPath() is actual Page (usually, /foo/bar).
so, if you have something like:
<%
iter = queryResult.getNodes(); //returns cq:Page nodes
while (iter.hasNext()) {
sling.include(iter.nextNode().getPath());// resource of the script included will be jcr:content
}%>
However, if you specify resourceType for include,
For example, SlingScriptHelper
with RequestDispatcherOptions.setForceResourceType() or, <sling:include resourceType="..."/>, the included script (handler)'s resource is NOT jcr:content but the resource itself. (Not /foo/bar/jcr:content, but /foo/bar.. where included resource was /foo/bar).
Okay, this is hairy.
Let's work an example.
The client request was:
GET /x/y.html
/x/y's resourceType (handler) is /apps/a/handler.
In /apps/a/handler/handler.jsp, you include /foo/bar (a cq:Page). /foo/bar's resourceType is /apps/b/handler.
You include:
<sling:include path="/foo/bar.html"/>
then /apps/b/handler will be used.
resource is /foo/bar/jcr:content
currentNode is /foo/bar/jcr:content
currentPage is /foo/bar
<sling:include path="/foo/bar" resourceType="c/handler'/>
/apps/c/handler is used
resource is /foo/bar
currentNode is /foo/bar
currentPage is /x/y
No comments:
Post a Comment
If you have any doubts or questions, please let us know.