[xwiki-users] Passing arguments to Groovy object constructor
Hello, Is it possible to pass arguments to a Groovy object instantiated using xwiki.parseGroovyFromPage("Blah.Blah"), or is there some other way to do it? Thanks, Joshua
Hi, On Tue, Dec 1, 2009 at 20:44, Rieken, Joshua <[email protected]> wrote:
Hello,
Is it possible to pass arguments to a Groovy object instantiated using xwiki.parseGroovyFromPage("Blah.Blah"), or is there some other way to do it?
You could have some init() methods in your groovy class to call when you have the objects.
Thanks, Joshua
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
On Dec 1, 2009, at 8:44 PM, Rieken, Joshua wrote:
Hello,
Is it possible to pass arguments to a Groovy object instantiated using xwiki.parseGroovyFromPage("Blah.Blah"), or is there some other way to do it?
BTW note that in XWiki Syntax 2.0 parseGroovyFromPage isn't needed. You can use the {{groovy}} and {{include}} macros instead. -Vincent
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Thomas Mortagne Sent: Tuesday, December 01, 2009 2:39 PM To: XWiki Users Subject: Re: [xwiki-users] Passing arguments to Groovy object constructor
Hi,
On Tue, Dec 1, 2009 at 20:44, Rieken, Joshua <[email protected]> wrote:
Hello,
Is it possible to pass arguments to a Groovy object instantiated using xwiki.parseGroovyFromPage("Blah.Blah"), or is there some other way to do it?
You could have some init() methods in your groovy class to call when you have the objects.
Ah, yes, that will work for many uses. To be more specific, what I'm looking to do is create a class that extends groovy.io.File. A File does not have a constructor that takes zero arguments, so I was looking for a way to pass arguments when the object is created rather than calling an init(). Otherwise, I can't even instantiate the object without just hardcoding the path into the class, which is not a viable option. Any suggestions? Thanks, Joshua
Thanks, Joshua
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Vincent Massol Sent: Tuesday, December 01, 2009 2:55 PM To: XWiki Users Subject: Re: [xwiki-users] Passing arguments to Groovy object constructor
On Dec 1, 2009, at 8:44 PM, Rieken, Joshua wrote:
Hello,
Is it possible to pass arguments to a Groovy object instantiated using xwiki.parseGroovyFromPage("Blah.Blah"), or is there some other way to do it?
BTW note that in XWiki Syntax 2.0 parseGroovyFromPage isn't needed. You can use the {{groovy}} and {{include}} macros instead.
-Vincent
Thank you! This solved my issue. I was able to wrap the class in its own page with {{groovy}} {{/groovy}}, {{include}} that document, and create a new object with constructor arguments. -Joshua
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (3)
-
Rieken, Joshua -
Thomas Mortagne -
Vincent Massol