Home β€Ί Core Learning Journey β€Ί Session 3 β€” Sling & resource resolution

Session 3 β€” Sling & resource resolution

Purpose: Learn how Sling turns a URL into content plus a rendering script β€” the routing heart of AEM.

Who this page is for

AudienceWhy it matters to you
All engineersEvery "why is this rendering that?" question ends here

Routing is inverted

React Router maps URL β†’ component, which then fetches data. Sling maps URL β†’ content first, and the content itself declares its renderer via sling:resourceType. Data picks the component, not the other way round.

GET /content/phi/plans/gold-hospital.summary.html
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”¬β”€β”€β”˜ β””β”€β”¬β”€β”˜
            resource path      selector  extension

1. Resolve path β†’ node /content/phi/plans/gold-hospital (its jcr:content)
2. Read sling:resourceType β†’ phi-academy/components/planpage
3. Find best script in /apps/phi-academy/components/planpage/
   matching selector+extension β†’ summary.html (HTL)
4. Execute script with the resource as context

URL anatomy

PartExampleUse
Resource path/content/phi/plans/gold-hospitalWhich content
Selector(s).summary, .cardWhich *variant* of rendering β€” free variation without new routes
Extension.html, .jsonWhich format
Suffix/2026/07 after the extensionExtra path-like parameters

Selectors are the underrated superpower: one plan page can render as full page (.html), teaser card (.card.html), or data (.model.json) β€” same content, different scripts.

Script resolution order (per component)

  1. Script named after selector(s): summary.html
  2. Default: <componentName>.html (e.g. planpage.html)
  3. Walk up sling:resourceSuperType inheritance chain
  4. Fall back to servlets registered by resourceType

Component inheritance via sling:resourceSuperType is how the Core Components pattern works: your phi-academy/components/planpage can extend core/wcm/components/page/v3/page and override only what differs β€” like extending a base class but for render scripts.

Everything is a resource

Servlets, JSON views, even synthetic (non-JCR) data can be resources. The uniform interface β€” resource.adaptTo(SomeModel.class) β€” is the platform's version of "everything is a stream of props".

Quick navigation