Unified API to get page path with jcr:content | Community
Skip to main content
Peter_Puzanovs
Community Advisor
Community Advisor
April 4, 2018
Solved

Unified API to get page path with jcr:content

  • April 4, 2018
  • 2 replies
  • 1237 views

Hi,

When using AEM API's sometimes pages are returned from methods come with jcr:content and sometimes without jcr:content.

Checking for jcr:content and then concat it, does not feel right.

Is there an API in AEM/Sling to do this for us?


Regards,

Peter

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by joerghoh

That behavior does very likely happen only when you use JCR query.  But it's very easy to cope with that:

resource r = ...

Page p  = r.adaptTo(Page.class)

and voila, it's normalized. But then try to avoid working on the page path (via p.getPath()) via String operations.

Jörg

2 replies

smacdonald2008
Level 10
April 4, 2018

When working with Pages - for example - are you using PageManager API?

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
April 4, 2018

That behavior does very likely happen only when you use JCR query.  But it's very easy to cope with that:

resource r = ...

Page p  = r.adaptTo(Page.class)

and voila, it's normalized. But then try to avoid working on the page path (via p.getPath()) via String operations.

Jörg