Thanks Vincent, You're right it will be easier through context... Do "$context" (velocity) and "context" (groovy) variables refer to the application context or to the session context ? Jeremie 2010/2/1 Vincent Massol <[email protected]>
Hi Jeremie,
On Feb 1, 2010, at 10:11 AM, Jeremie BOUSQUET wrote:
Hi all,
I use method parseGroovyFromPage() to instantiate an object from a Groovy class stored in a page.
It works well, but now I would like to forbid multiple executions of this class. To do so, I changed it to be a singleton, setting the constructor as private. Of course, now, parseGroovyFromPage() returns that the object can't be instantiated ... As the call to the constructor is inside this method, I can't change it to just call getInstance().
Are there any workarounds, or other ways to achieve this ?
Why do you need to use this method?
With XWiki Syntax 2.0 we now have the ability to do:
{{include document="groovypage"/}}
where groovypage is a page using the {{groovy}} macro to define groovy code.
If you want to forbid several executions of the {{groovy}} script you could use an if() inside it and check if a value is present in the session or application context (depending if you want it called once per user or per application).
Thanks -Vincent
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users