I'm doing a simple CQ include which includes my component.
The currentNode object contains the resolved JCR Node for the request. Since you are using design dialog, you will be able to access the The design of the addressed resource using the currentDesign object. And in order to access the properties stored in the design dialog you can use the currentStyle object.
Since we have the currentStyle object, we can get the path of the style from that and then use the Session object to get the node from that path. After that you can perform all the node operations on it.
<cq:include path="banner" resourceType="generic/components/content/banner" />
But instead of using a content dialog I am using a design dialog. I understand the design dialog properties are all stored under /etc/designs/default. So if I try to access the current node object I.E. use:<%= currentNode.getName() %>
I get a null pointer exception.The currentNode object contains the resolved JCR Node for the request. Since you are using design dialog, you will be able to access the The design of the addressed resource using the currentDesign object. And in order to access the properties stored in the design dialog you can use the currentStyle object.
currentStyle.get("prop_name"); currentDesign.getId();
Refer to Style api and Design api for information on the methods available.Since we have the currentStyle object, we can get the path of the style from that and then use the Session object to get the node from that path. After that you can perform all the node operations on it.
Session session = resourceResolver.adaptTo(Session.class);
if(session.nodeExists(currentStyle.getPath())) {
Node node = session.getNode(currentStyle.getPath());
node.getIdentifier();
}
Comments
Post a Comment