Expand my Community achievements bar.

SOLVED

currentNode is null

Avatar

Level 5

We are facing issue similar to below thread, but we don't want to use querymanager but rather use the currentNode object

http://stackoverflow.com/questions/18850171/currentnode-object-gives-nullpointerexception

 

In our code we have something like below:

In the control tabControlPG, we are using currentNode.getProperty(). currentNode is always null. So I tried using request.getResource() and even that throws error that getResource() is not availble for HttpServletRequest.

 

Any ideas or pointers are really appreciated.

<%if(currentPage.getName().equalsIgnoreCase("Documents-Publications")) {%>
        <cq:include path="mainContent/tabcontrol" resourceType="/apps/imf/mobile/components/content/customComponents/tabControl"/>
    <%}
    else if(currentPage.getName().equalsIgnoreCase("logistics")) {%>
        <cq:include path="mainContent/tabcontrol" resourceType="/apps/imf/mobile/components/content/customComponents/tabControlPG"/>                
    <%}%>

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

I think you are getting currentNode and resource as null in the included script may be because you are setting "path" as virtual as it is pointing to a non existent node in CRX. If that node does not exist then these tags won't inject the resource/node in the request context for processing. Whatever node you want to access in the included JSP, you should set the path to that particular node. 

 

Please see the documentation here - 

https://docs.adobe.com/docs/en/cq/5-6/howto/taglib.html#%3Ccq:include%3E

https://sling.apache.org/documentation/bundles/sling-scripting-jsp-taglib.html

View solution in original post

4 Replies

Avatar

Employee Advisor

Have you tried using <sling:include> tag for this use case ? 

<sling:include path="mainContent/tabcontrol" resourceType="imf/mobile/components/content/customComponents/tabControlPG" />

Avatar

Correct answer by
Employee Advisor

I think you are getting currentNode and resource as null in the included script may be because you are setting "path" as virtual as it is pointing to a non existent node in CRX. If that node does not exist then these tags won't inject the resource/node in the request context for processing. Whatever node you want to access in the included JSP, you should set the path to that particular node. 

 

Please see the documentation here - 

https://docs.adobe.com/docs/en/cq/5-6/howto/taglib.html#%3Ccq:include%3E

https://sling.apache.org/documentation/bundles/sling-scripting-jsp-taglib.html

Avatar

Level 5

Thanks for your tip. Will try and let you know if it works