Hi Matthias,
The recommended approach is to use a page template. See the FAQ
tutorial for instance
http://platform.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorialManual .
You create a page that will serve as a template. You add an object of
the desired type to this page and fill the object properties with the
default values. Then you use this page as a template when creating new
pages. See also the template provider feature
http://extensions.xwiki.org/xwiki/bin/view/Extension/Administration+Applica…
.
If you want to add the object even when the user creates a plain wiki
page then you need to write an event listener that catches the
document creation event and adds the object. It can be written in
Groovy, Java (check
extensions.xwiki.org for examples) or as a Wiki
component I think (
http://extensions.xwiki.org/xwiki/bin/view/Extension/WikiComponent+Module
).
Hope this helps,
Marius
On Fri, Oct 18, 2013 at 10:25 PM, Matthias Wegner <mic.mat.wegner(a)web.de> wrote:
Hi,
i didnt find a documentation for creating an XObject to a Wiki-Page when a
new Page is created.
I think it must something like that, but who do i place it?
EntityReference entRef = doc.resolveClassReference("Space.WhateverClass");
int objectIndex = doc.createXObject(entRef, getXWikiContext());
BaseObject o = doc.getXObjects(entRef).get(objectIndex);
I know i can create a new object and page by velocity
(
http://extensions.xwiki.org/xwiki/bin/view/Extension/Create+Page+With+Object),
but i want to add a default and predefined object when a user add a new
page.
Is there a way to do this from plugin-side?
Regards,
Matthias
--
View this message in context:
http://xwiki.475771.n2.nabble.com/Create-Object-by-Default-with-a-new-Page-…
Sent from the XWiki- Dev mailing list archive at
Nabble.com.
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs