Hi Anamaria,
On Tue, Jan 5, 2010 at 8:20 PM, Anamaria Stoica <anam.stoica(a)gmail.com>wrote;wrote:
Hi,
Is it possible to write XWiki components that create new pages without
having as a dependency the old xwiki core?
Let's say the component currently has the following code snippet:
XWiki xwiki = xwikiContext.getWiki();
XWikiDocument newDocument = new XWikiDocument();
newDocument.setFullName(documentName, xwikiContext);
newDocument.setContent(templateDoc.getContent());
newDocument.setSyntaxId("xwiki/2.0");
newDocument.setCreator(xwikiContext.getLocalUser());
newDocument.setAuthor(xwikiContext.getLocalUser());
newDocument.setTitle(someString);
xwiki.saveDocument(newDocument, xwikiContext);
How should the code be written so it will be easier to change when the code
refactoring comes to an end?
You can use the xwiki-bridge module to accomplish this. Now I haven't used
the new xwiki-model component myself a lot but if you have a look at
DocumentAccessBridge in xwiki-bridge component, you'll see how to do this.
- Asiri