so I have the following code snippet
import com.day.cq.wcm.api.Page;
import com.day.cq.wcm.api.PageManager;
...
...
//more unrelated code here
...
...
Page currentPage = pageManager.getPage("/content/data/fishes/greatwhite");
log.error(currentPage.getTitle());
from what I understand (PageManager ("The Adobe AEM Quickstart and Web Application.") ), getPath requires a String input.
And from the code snippet I have provided above, the path I provided is valid. I checked this via CRX/DE.
I've looked at various examples around the net and I cannot find examples where the string supplied to getPath is a string literal. It's always a variable.
I'm just wondering what sort of path is required.
When I debugged my code using Eclipse, currentPage is neither empty or null. like it's undefined. so perhaps I'm using it wrong.
Thanks
Solved! Go to Solution.
Documentation is correct, it has to be the path to the page in repository (string)
Use the sample working code below, make sure you get pageManager object before you do getTitle
ResourceResolver resourceResolver = request.getResourceResolver();
PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
Page currentPage = pageManager.getPage("/content/page/en/");
response.getWriter().println("Hello from " + currentPage.getTitle());
Code depicts the use case in a servlet to get resource resolver need for pagemanager, though you can refer to this doc if you are not use in servlet to get access to resourceresolver
Documentation is correct, it has to be the path to the page in repository (string)
Use the sample working code below, make sure you get pageManager object before you do getTitle
ResourceResolver resourceResolver = request.getResourceResolver();
PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
Page currentPage = pageManager.getPage("/content/page/en/");
response.getWriter().println("Hello from " + currentPage.getTitle());
Code depicts the use case in a servlet to get resource resolver need for pagemanager, though you can refer to this doc if you are not use in servlet to get access to resourceresolver
You can also do first a getResource(), to make you are working an existing resource.
Then do resource.getPath() as input to getPage()
Views
Replies
Total Likes
Q : The pageManager work for me in Author but does not work in publisher. Seems like it is unable to get the data. Have anyone faced this issue ?
Views
Replies
Total Likes
Do you mean that anonymous user doesn't work for this use case but when you login with admin on pubs it works fine?
If yes, use service user and assign appropriate permissions on specific path hierarchy. Modify the code as applicable.
http://www.aemcq5tutorials.com/tutorials/create-system-user-in-aem/
Views
Replies
Total Likes
Views
Likes
Replies