Session 3 β Sling & resource resolution
Who this page is for
| Audience | Why it matters to you |
|---|---|
| All engineers | Every "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
| Part | Example | Use |
|---|---|---|
| Resource path | /content/phi/plans/gold-hospital | Which content |
| Selector(s) | .summary, .card | Which *variant* of rendering β free variation without new routes |
| Extension | .html, .json | Which format |
| Suffix | /2026/07 after the extension | Extra 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)
- Script named after selector(s):
summary.html - Default:
<componentName>.html(e.g.planpage.html) - Walk up
sling:resourceSuperTypeinheritance chain - 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".