Hi,
Depending on what you want to achieve, you could create various types of
pages:
- Top level document (non-terminal): new DocumentReference("myWiki",
"myTopLevelPage", "WebHome")
- Second level document (non-terminal), under the "Main" space: new
DocumentReference("myWiki", Arrays.asList("Main",
"SecondLevelPage"),
"WebHome")
- Deeper level document (non-terminal): new DocumentReference("myWiki",
Arrays.asList("TopLevelParentPage", "SecondLevelParentPage", ....,
"MyDeeperLevelPage"), "WebHome")
- Top level terminal document, under the "Main" space: new
DocumentReference("myWiki", "Main", "MyTerminalPage")
- Deeper level terminal document: new DocumentReference("myWiki",
Arrays.asList("TopLevelParentPage", "SecondLevelParentPage", ....,
"MyDeeperLevelParent"), "MyTerminalPage")
There are various signatures of the DocumentReference constructor [1], the
general rules are that:
* you need to know if you are creating a terminal or a non-terminal
document and
* to understand that:
** the name of the non-terminal document is actually the last space name
(in its document reference, with the page name always being "WebHome") and
that
** the name of a terminal document is simply its page name (in its document
reference).
Also note that in 7.2 we have deprecated the parent-child notion and that
the setParentReference call you are performing is now deprecated (will go
away soon). The parent of a document is now resulting from its reference
[2].
Hope this helped and that it did not confuse you more :)
-Eduard
----------
[1]
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwi…
[2]
http://platform.xwiki.org/xwiki/bin/view/Features/ContentOrganization
On Wed, Nov 25, 2015 at 2:11 PM, Marius Dumitru Florea <
mariusdumitru.florea(a)xwiki.com> wrote:
On Wed, Nov 25, 2015 at 10:54 AM, gervwyk
<gervwyk(a)gmail.com> wrote:
Hello.
How would I create a new space under Main or the toplevel entity from a
java
component. So far I'm doing this, but not sure..
DocumentReference docref = new
DocumentReference(serverName,pageSpace,pageName);
if(xwiki.exists( docref, xcontext)){
//skip create do other stuff
}else{
XWikiDocument doc = new XWikiDocument(docref);
doc.setTitle(pageName);
DocumentReference docrefparent = new
DocumentReference(serverName,pageSpace,"WebHome");
doc.setParentReference(docrefparent);
xwiki.saveDocument(doc, xcontext);
}
Where:
serverName = $request.serverName
The first parameter is the wiki name, not the server name. If I print
$request.serverName in Velocity I get "localhost" which is not the wiki
name ("xwiki" for the main wiki in my case). $xcontext.database should give
you the name of the current wiki.
Hope this helps,
Marius
pageSpace = "Main"
pageName = "NewPage"
is there anything else I need to set on the document or am I referencing
wrong? Not sure why it is not creating the page..
--
View this message in context:
http://xwiki.475771.n2.nabble.com/Create-spaces-and-page-in-toplevel-space-…
Sent from the XWiki- Users mailing list archive
at
Nabble.com.
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users