2014-02-16

Tags: CQ5-AEM JSP

CQ5 Developing Components has a lot of information, but I wanted a handier cheat sheet.

Table 1. Objects from <cq:defineobjects/> (as of CQ5.6)
Name JavaDoc Description my favorite methods

component

Component

the current AEM component object of the current resource

getName() / getPath()

componentContext

ComponentContext

the current component context object of the request

getPage() / getResource() / setDecorate(boolean)

currentDesign

Design

the current design object of the current page

getStaticCssPath() / getStyle(_) / writeCss(Writer, boolean) / writeCssIncludes(_)

currentPage

Page

the current AEM WCM page object

getName() / getTitle() / getNavigationTitle() / getTags() / getContentResource() / getDepth() / getPageManager()

currentStyle

Style

the current style object of the current cell

-

designer

Designer

the designer object used to access design information

getDesign(_) / getStyle(_)

editContext

EditContext

the edit context object of the AEM component

-

pageManager

PageManager

the page manager object for page level operations

getPage(path) / create/ copy/ delete/ move/ order(_) / getRevisions(_)

pageProperties

InheritanceValueMap

the page properties object of the current page

getInherited(name,default) / get(name,default) / put(key,val)

properties

ValueMap

the properties object of the current resource

get(name,defaultVal) / put(key,val) examples

resourceDesign

Design

the design object of the resource page

see currentDesign

resourcePage

Page

the resource page object

see currentPage

Attributes provided by cq:defineObjects:

  • componentContextName

  • componentName

  • currentDesignName

  • currentPageName

  • currentStyleName

  • designerName

  • editContextName

  • logName

  • nodeName

  • pageManagerName

  • pagePropertiesName

  • propertiesName

  • requestName

  • resourceDesignName

  • resourceName

  • resourcePageName

  • resourceResolverName

  • slingName

The <cq:defineObjects> tag also automatically includes <sling:defineObjects/>

Table 2. Objects from <sling:defineObjects/> (as of CQ5.6)
Name JavaDoc Description my favorite methods

currentNode

Node

JCR node for current resource (not defined if not)

discourage in favor of Resource or ValueMap addNode(_) / getUUID()

log

SLF4J.Logger

Provides an SLF4J Logger for logging to the Sling log system from within scripts

error / warn / info / debug

resource

Resource

the current Resource object to handle (depending on the URL of the request)

getName() / getPath() / getChild(path) / getChildren()

resourceResolver

ResourceResolver

The current ResourceResolver object

create(args) / commit() / getResource(_) / resolve(_) / queryResources(query, lang)

sling

SlingScriptHelper

convenience methods for scripts. GOD Object.

getService(Class) / include(_) / forward(_) / getRequest() / getResponse() / getScript()

slingRequest

SlingHttpServletRequest

extends HttpServletRequest

getResource() / getCookie(name) / getRequestParameterMap() / getRequestParameters(name) / getRequestPathInfo()

slingResponse

SlingHttpServletResponse

extends HttpServletResponse

static fields / addCookie(cookie) / getOutputStream() / getWriter()

Attributes provided by sling:defineObjects:

  • logName

  • nodeName

  • requestName

  • resourceResolverName

  • responseName

  • slingName

I hope this helps others and myself.