On 09/21/2010 11:57 PM, Thomas Mortagne wrote:
On Tue, Sep 21, 2010 at 22:22, Marius Dumitru Florea <[email protected]> wrote:
Hi devs,
If I write:
{{groovy}} print com.xpn.xwiki.web.Utils.getComponent(org.xwiki.model.ModelContext.class).getCurrentEntityReference(); {{/groovy}}
in a wiki page I get:
name = [xwiki], type = [WIKI], parent = [null]
I was expecting to get a reference to the current page (i.e. the page that executes the groovy script). The javadoc of ModelContext interface says:
"Allows accessing Model Objects for current objects (current document, current wiki, current space, etc) placed in the Execution Context."
The javadoc is not very clear, ModelContext return the current model entity and not the current execution document. For now it's just the current wiki, the wiki in which the model is working, the script related current document has nothing to do with the model.
To be more clear it returns $context.wiki and not $context.document which are two different things.
Makes sense now.
When you want the current document you can use the DocumentAccessBridge (getCurrentDocumentReference).
Yep, I already changed my code to use DocumentAccessBridge. Thanks for the explanation, Marius
Looks like DefaultModelContext ( http://svn.xwiki.org/svnroot/xwiki/platform/core/trunk/xwiki-model/src/main/... ) always returns a WikiReference. What was the rationale behind this?
Thanks, Marius _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs