How does this component get the list of child pages?
How does this component get the list of child pages?
A. Instantiate a node object with session.getNode(/content/blogs) and then iterate through the child nodes and print the title for each.
B. Use PageManager.getPage(“/content/blogs”) of the static PageManager class to instantiate a Page object and then iterate through the child pages and print the title for each.
C. Use the QueryDebugger to look for all children of /content/blogs and then iterate through the result set and print the title for each.
D. Adapt the resourceResolver to the PageManager service, then use the getPage(/content/blogs) to instantiate a Page object and then iterate through the child pages and print the title for each.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @cmr96960454
Each option has its pros and cons:
A. Instantiate a node object with session.getNode(/content/blogs) and then iterate through the child nodes and print the title for each.
I would not recommend it as in this case you will have to iterate each and every node including structure/component nodes under page. Basically you will have to apply your own check to identify if it is a page node.
B. Use PageManager.getPage(“/content/blogs”) of the static PageManager class to instantiate a Page object and then iterate through the child pages and print the title for each.
I do not understand what you mean by static PageManager
C. Use the QueryDebugger to look for all children of /content/blogs and then iterate through the result set and print the title for each.
This option is good and you can apply conditions to get specific blog pages conditionally on properties.
For large number of pages, this is better option as you can optimize the performance as well with oak:index.
D. Adapt the resourceResolver to the PageManager service, then use the getPage(/content/blogs) to instantiate a Page object and then iterate through the child pages and print the title for each.
This seems to be good option too and as seems more appropriate if your usecase is just iteration and displaying of blogs. But in future if number of pages increases to 100K or so, iteration can take up a lot of time. Also, you have to filter blog pages such as by date, Go for option C.
Thanks,
Nupur
Hi @cmr96960454
Each option has its pros and cons:
A. Instantiate a node object with session.getNode(/content/blogs) and then iterate through the child nodes and print the title for each.
I would not recommend it as in this case you will have to iterate each and every node including structure/component nodes under page. Basically you will have to apply your own check to identify if it is a page node.
B. Use PageManager.getPage(“/content/blogs”) of the static PageManager class to instantiate a Page object and then iterate through the child pages and print the title for each.
I do not understand what you mean by static PageManager
C. Use the QueryDebugger to look for all children of /content/blogs and then iterate through the result set and print the title for each.
This option is good and you can apply conditions to get specific blog pages conditionally on properties.
For large number of pages, this is better option as you can optimize the performance as well with oak:index.
D. Adapt the resourceResolver to the PageManager service, then use the getPage(/content/blogs) to instantiate a Page object and then iterate through the child pages and print the title for each.
This seems to be good option too and as seems more appropriate if your usecase is just iteration and displaying of blogs. But in future if number of pages increases to 100K or so, iteration can take up a lot of time. Also, you have to filter blog pages such as by date, Go for option C.
Thanks,
Nupur
My two cents on this one.
QueryDebugger should be used to perform dry runs to see how your JCR queries are performing and optimize them accordingly.
QueryDebugger should not be your primary way of implementing the given business logic.
Also, session.getNode will require a lot more house keeping without any added benefits. you will get the required output but not without putting extra effort in terms of filtering page nodes from other node types
So , i think the correct answer is
D - Adapt the resourceResolver to the PageManager service, then use the getPage(/content/blogs) to instantiate a Page object and then iterate through the child pages and print the title for each.
This way, any ACL restrictions on the content tree are also honored.
Views
Replies
Total Likes
looks perfect answer..!!
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies