cq5 - How to get url of all child,grand child pages using root path? -


i have path of root page , want retrieve child pages of root page , grandchild , grand grand child of root page. structure this

rootpage     |     |     |---------childpage                     |                     |                     |---------grandchildpage                                     |                                     |                                     |                                     |----------------------grandgrandchildpages 

so want path of these pages. how can this? i'm using this

adminsession = repository.loginadministrative( repository.getdefaultworkspace());                    resourceresolver resourceresolver = request.getresourceresolver();                    pagemanager pagemanager = resourceresolver.adaptto(pagemanager.class);                    list<string>pagelist = new arraylist();                     page rootpage = pagemanager.getpage("/content/abc/roi");                     iterator<page> rootpageiterator = rootpage.listchildren();                     while(rootpageiterator.hasnext())                     {                     page childpage =    rootpageiterator.next();                     string path = childpage.getpath();                     pagelist.add(path);                          } 

but provides me child pages of root page , if use rootpage.haschild() have pass string can't because don't name of pages. there method returns boolean value whether page has child pages or not. want list of pages inside root page include grandchild grandgrandchild of root page.

can ?

from aem 5.6 onwards, can use listchildren(filter<page> filter, boolean deep) method available in com.day.cq.wcm.api.page interface.

this accept pagefilter , boolean value arguments.

the pagefilter can used, if want filter invalid , hidden pages. if want pages listed pass null param.

for boolean deep, if false lists child pages, , if true list descendants of given page.

hence, code in question can modified either

iterator<page> rootpageiterator = rootpage.listchildren(null, true); 

or

iterator<page> rootpageiterator = rootpage.listchildren(new pagefilter(), true); 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -