March 18, 2020
Estimated Post Reading Time ~

What is Global.jsp in AEM/Adobe CQ5

What is Global.jsp?
Why we include Global.jsp?
Why Global.jsp should be included in every component rendering JSP script?
The Adobe provided global.jsp declares the Sling, CQ and JSTL taglibs and exposes the regularly used scripting objects defined by the tag.
When you develop the JSP script of a CQ5 component, it is recommended to
include the following code at the top of the script:
<%@include file=”/libs/foundation/global.jsp”%>
It provides quick access to specific objects (i.e. to access content) to any JSP script file used to render a component.
The Global.jsp shortens and simplifies the JSP code of your component.
Therefore, global.jsp should be included in every component rendering JSP script where one or more of the objects provided in global.jsp are used. 

The <cq:defineObjects> tag exposes the following, regularly used, scripting objects which can be referenced by the developer. It also exposes the objects defined by the <sling:defineObjects> tag.
· slingRequest – The wrapped Request Object (SlingHttpServletRequest).
· slingResponse – The wrapped Response Object (SlingHttpServletResponse).
· resource – The Sling Resource Object (slingRequest.getResource();).
· resourceResolver – The Sling Resource Resolver Object (slingRequest.getResoucreResolver();).
· currentNode – The resolved JCR node for the request.
· log – The Default logger().
· sling – The Sling script helper.
· properties – The properties of the addressed resource (resource.adaptTo(ValueMap.class);).
· pageProperties – The properties of the page of the addressed resource.
· pageManager – The page manager for accessing CQ content pages (resourceResolver.adaptTo(PageManager.class);).
· component – The component object of the current CQ5 component.
· designer – The designer object for retrieving design information (resourceResolver.adaptTo(Designer.class);).
· currentDesign – The design of the addressed resource.
• current style – The style of the addressed resource.



By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.