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. When you want the current document you can use the DocumentAccessBridge (getCurrentDocumentReference). > > Looks like DefaultModelContext ( > http://svn.xwiki.org/svnroot/xwiki/platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/internal/DefaultModelContext.java > ) always returns a WikiReference. What was the rationale behind this? > > Thanks, > Marius > _______________________________________________ > devs mailing list > [email protected] > http://lists.xwiki.org/mailman/listinfo/devs > -- Thomas Mortagne _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs

