[xwiki-users] Get all children from current document in Java component
Hello I'm trying to get all the documents that list the current document as the perant using: List<DocumentReference> childDocs = doc.getChildrenReferences(xcontext); where doc is the parent XWikiDocument. However the function only return an empty list, althoug there is documents in the space. If I print doc.getFullName() its AAA.WebHome.. And all the chldren spaces is listed under AAA.. how should I reference doc to get say AAA.BBB.WebHome in the list? or where am I going wrong? -- View this message in context: http://xwiki.475771.n2.nabble.com/Get-all-children-from-current-document-in-... Sent from the XWiki- Users mailing list archive at Nabble.com.
On Tue, Dec 1, 2015 at 2:51 PM, gervwyk <[email protected]> wrote:
Hello I'm trying to get all the documents that list the current document as the perant using: List<DocumentReference> childDocs = doc.getChildrenReferences(xcontext);
where doc is the parent XWikiDocument.
However the function only return an empty list, althoug there is documents in the space.
XWikiDocument#getChildrenReferences() takes into account only the parent field, which was used in the past (<7.2) to organize the wiki pages in a tree hierarchy. Starting with 7.2 the wiki pages are organized as nested pages, see http://www.xwiki.org/xwiki/bin/view/ReleaseNotes/ReleaseNotesXWiki72M2#HHidi... , and the parent-child relationship has been hidden from the UI. if you wan to get the list of child pages based on the new 'reference' hierarchy mode (i.e. nested pages) then you need to use the QueryManager with the proper HQL/XWQL statement. For all descendants, see https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik... For only direct children, see https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik... For the future, we'll have to implement a component to provide tree-oriented APIs regarding wiki pages. Hope this helps, Marius
If I print doc.getFullName() its AAA.WebHome.. And all the chldren spaces is listed under AAA.. how should I reference doc to get say AAA.BBB.WebHome in the list? or where am I going wrong?
-- View this message in context: http://xwiki.475771.n2.nabble.com/Get-all-children-from-current-document-in-... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (2)
-
gervwyk -
Marius Dumitru Florea