Index: xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java =================================================================== --- xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java (revision 22815) +++ xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java (working copy) @@ -3175,13 +3175,37 @@ return pageNames; } + /** + * Returns a list of fullNames of all documents which list this document as their parent + * + * {@link #getChildren(int, int, com.xpn.xwiki.XWikiContext)} + */ public List getChildren(XWikiContext context) throws XWikiException { - String[] whereParams = - {this.getWikiName() + ":" + this.getFullName(), this.getFullName(), this.getName(), this.getSpace()}; + return getChildren(0, 0, context); + } - String whereStatement = "doc.parent=? or doc.parent=? or (doc.parent=? and doc.space=?)"; - return context.getWiki().getStore().searchDocumentsNames(whereStatement, Arrays.asList(whereParams), context); + /** + * Returns a list of fullNames of all documents which list this document as their parent + * + * @param nb The number of results to return. + * @param start The number of results to skip before we begin returning results. + * @param context The {@link com.xpn.xwiki.XWikiContext context}. + * @return List of fullNames of documents + * @throws XWikiException If there's an error querying the database. + */ + public List getChildren(int nb, int start, XWikiContext context) throws XWikiException + { + String[] whereParams = { + this.getWikiName() + ":" + this.getFullName(), + this.getFullName(), + this.getName(), + this.getWikiName() + ":" + this.getName(), + this.getSpace() + }; + + String whereStatement = "doc.parent=? or doc.parent=? or ((doc.parent=? or doc.parent=?) and doc.space=?)"; + return context.getWiki().getStore().searchDocumentsNames(whereStatement, nb, start, Arrays.asList(whereParams), context); } public void renameProperties(String className, Map fieldsToRename) Index: xwiki-core/src/main/java/com/xpn/xwiki/api/Document.java =================================================================== --- xwiki-core/src/main/java/com/xpn/xwiki/api/Document.java (revision 22815) +++ xwiki-core/src/main/java/com/xpn/xwiki/api/Document.java (working copy) @@ -1538,7 +1538,7 @@ } /** - * Get document children. Children are document with the current document as parent. + * Get document children. Children are documents with the current document as parent. * * @return The list of children for the current document. * @since 1.8 Milestone 2 @@ -1549,6 +1549,20 @@ } /** + * Get document children. Children are documents with the current document as parent. + * Where a document has a large number of children, one may desire to return a certain number + * of children (nb) and skip some number (start) of the first results. + * + * @param nb The number of results to return. + * @param start The number of results to skip before we begin returning results. + * @return The list of children for the current document. + */ + public List getChildren(int nb, int start) throws XWikiException + { + return this.doc.getChildren(nb, start, getXWikiContext()); + } + + /** * @return "inline" if the document should be edited in inline mode by default or "edit" otherwise. * @throws XWikiException if an error happens when computing the edit mode */