0

I'm creating a simple class that simply gets the root of the page that you are on. Most of my pages are three levels deep and I need to always find the root.

I'm using slings resource resolver to adapt to the PageManager class. Once I adapt to the pageManager class I'm trying to get the root page.

ResourceResolver resourceResolver = resource.getResourceResolver();
PageManager pageManager = resourceResolver.adaptTo(PageManager);

this.pageRoot = pageManager.getPage(currentStyle.get("pageroot", "/noPage"));

Everytime I run this I get some weird combination of below:

com.day.cq.wcm.core.impl.PageImpl@1fb4792

No errors or nothing. Any ideas? Any help is greatly appreciated.

Delmon Young
  • 2,013
  • 5
  • 39
  • 51

1 Answers1

4

I think there is nothing wrong in the way PageManager is working.

PageManager.getPage("path") returns you a Page object.

And i guess you are directly trying to print the page object, due to which you are seeing the above combination.

Try to use the page object, for whatever reason you are obtaining it or use any of the methods supported by Page class such as getPath() or getName() and you might be able to see the details of that particular page.

And moreover currentStyle.get("pageroot", "/noPage") is anyway gonna give you the path of the root page, so there is no need to use pageManager.

rakhi4110
  • 9,253
  • 2
  • 30
  • 49