Accessing Groovy function from velocity
Currently trying to work with both groovy and velocity for a project management class object. What I need to do is to initiate the groovy function from velocity (with a parameter set). Looking at the newsgroup archives it seems the way to do this is by using "parseGroovyFromString", which indeed returns an object - but how do I then take this and run the function (which in turn returns a result which I need to assess)? Brandon Esbach Software Engineer M/A-Com Eurotec Operations LoughMahon Technology Park, Skehard Road, Blackrock, Cork, Ireland Tel +353 21 4808305
Hi, I've taken advantage of your email to write a "tutorial" ( let's call it a beginning ;) on xwiki.org : http://www.xwiki.org/xwiki/bin/view/DevGuide/GroovyClassHelloWorldTutorial JV. 2007/2/15, Esbach, Brandon <Esbachb@tycoelectronics.com>:
Currently trying to work with both groovy and velocity for a project management class object. What I need to do is to initiate the groovy function from velocity (with a parameter set). Looking at the newsgroup archives it seems the way to do this is by using "parseGroovyFromString", which indeed returns an object - but how do I then take this and run the function (which in turn returns a result which I need to assess)?
Brandon Esbach Software Engineer M/A-Com Eurotec Operations LoughMahon Technology Park, Skehard Road, Blackrock, Cork, Ireland Tel +353 21 4808305
-- You receive this message as a subscriber of the xwiki-users@objectweb.org mailing list. To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org For general help: mailto:sympa@objectweb.org?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Hi JV, Very cool. I've linked your tutorial from http://www.xwiki.org/xwiki/ bin/view/DevGuide/Tutorials Thanks -Vincent On Feb 15, 2007, at 10:34 PM, Jean-Vincent Drean wrote:
Hi,
I've taken advantage of your email to write a "tutorial" ( let's call it a beginning ;) on xwiki.org : http://www.xwiki.org/xwiki/bin/view/DevGuide/ GroovyClassHelloWorldTutorial
JV.
2007/2/15, Esbach, Brandon <Esbachb@tycoelectronics.com>:
Currently trying to work with both groovy and velocity for a project management class object. What I need to do is to initiate the groovy function from velocity (with a parameter set). Looking at the newsgroup archives it seems the way to do this is by using "parseGroovyFromString", which indeed returns an object - but how do I then take this and run the function (which in turn returns a result which I need to assess)?
Brandon Esbach Software Engineer M/A-Com Eurotec Operations LoughMahon Technology Park, Skehard Road, Blackrock, Cork, Ireland Tel +353 21 4808305
-- You receive this message as a subscriber of the xwiki- users@objectweb.org mailing list. To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org For general help: mailto:sympa@objectweb.org?subject=help ObjectWeb mailing lists service home page: http:// www.objectweb.org/wws
-- You receive this message as a subscriber of the xwiki- users@objectweb.org mailing list. To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org For general help: mailto:sympa@objectweb.org?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/ wws
Ahh, nice job! Many thanks, it's a lot clearer now! -----Original Message----- From: Vincent Massol [mailto:vincent@massol.net] Sent: 16 February 2007 08:06 To: xwiki-users@objectweb.org Subject: Re: [xwiki-users] Accessing Groovy function from velocity Hi JV, Very cool. I've linked your tutorial from http://www.xwiki.org/xwiki/ bin/view/DevGuide/Tutorials Thanks -Vincent On Feb 15, 2007, at 10:34 PM, Jean-Vincent Drean wrote:
Hi,
I've taken advantage of your email to write a "tutorial" ( let's call it a beginning ;) on xwiki.org : http://www.xwiki.org/xwiki/bin/view/DevGuide/ GroovyClassHelloWorldTutorial
JV.
2007/2/15, Esbach, Brandon <Esbachb@tycoelectronics.com>:
Currently trying to work with both groovy and velocity for a project management class object. What I need to do is to initiate the groovy function from velocity (with a parameter set). Looking at the newsgroup archives it seems the way to do this is by using "parseGroovyFromString", which indeed returns an object - but how do I then take this and run the function (which in turn returns a
result which I need to assess)?
Brandon Esbach Software Engineer M/A-Com Eurotec Operations LoughMahon Technology Park, Skehard Road, Blackrock, Cork, Ireland Tel +353 21 4808305
-- You receive this message as a subscriber of the xwiki- users@objectweb.org mailing list. To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org For general help: mailto:sympa@objectweb.org?subject=help ObjectWeb mailing lists service home page: http:// www.objectweb.org/wws
-- You receive this message as a subscriber of the xwiki- users@objectweb.org mailing list. To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org For general help: mailto:sympa@objectweb.org?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/ wws
A small note about the separate groovy page (I made note of this in the page you put in JV): When you create the page, it cannot have "<%" and "%>". If it does, then it won't work (understandable, a lot of other languages work this way when a separate file used as a source, eg Javascript). However, this then results in your class being shown in plain text in the saved document (this occurs in B2 and B4, can't test B3 as it's not running on our test environment anymore) - which I would not like to see user's having any view access to. I'm unsure of what to suggest around this, or if it is even a concern. Naturally, if "parseGroovyFromString" would allow the "<%%>" then the page would be protected by default from the user (being correctly assessed as a Groovy page), BUT this is not quite a good solution. Perhaps it would help if there are some flags for the page that do not break the "parseGroovyFromString" method, but signify to Xwiki that the page is Groovy (and so needs programming rights to modify or save, and does not show content). For example: $doc.isVelocityInclude public class xyz { groovy code } Once the Xwiki engine sees $doc.isVelocityInclude, it treats the page as velocity and won't save without programming rights, and won't display it's content on viewing the document. Not sure if this is even an issue though. Thoughts? -----Original Message----- From: Esbach, Brandon [mailto:Esbachb@tycoelectronics.com] Sent: 16 February 2007 09:32 To: xwiki-users@objectweb.org Subject: RE: [xwiki-users] Accessing Groovy function from velocity Ahh, nice job! Many thanks, it's a lot clearer now! -----Original Message----- From: Vincent Massol [mailto:vincent@massol.net] Sent: 16 February 2007 08:06 To: xwiki-users@objectweb.org Subject: Re: [xwiki-users] Accessing Groovy function from velocity Hi JV, Very cool. I've linked your tutorial from http://www.xwiki.org/xwiki/ bin/view/DevGuide/Tutorials Thanks -Vincent On Feb 15, 2007, at 10:34 PM, Jean-Vincent Drean wrote:
Hi,
I've taken advantage of your email to write a "tutorial" ( let's call it a beginning ;) on xwiki.org : http://www.xwiki.org/xwiki/bin/view/DevGuide/ GroovyClassHelloWorldTutorial
JV.
2007/2/15, Esbach, Brandon <Esbachb@tycoelectronics.com>:
Currently trying to work with both groovy and velocity for a project management class object. What I need to do is to initiate the groovy function from velocity (with a parameter set). Looking at the newsgroup archives it seems the way to do this is by using "parseGroovyFromString", which indeed returns an object - but how do I then take this and run the function (which in turn returns a
result which I need to assess)?
Brandon Esbach Software Engineer M/A-Com Eurotec Operations LoughMahon Technology Park, Skehard Road, Blackrock, Cork, Ireland Tel +353 21 4808305
-- You receive this message as a subscriber of the xwiki- users@objectweb.org mailing list. To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org For general help: mailto:sympa@objectweb.org?subject=help ObjectWeb mailing lists service home page: http:// www.objectweb.org/wws
-- You receive this message as a subscriber of the xwiki- users@objectweb.org mailing list. To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org For general help: mailto:sympa@objectweb.org?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/ wws
2007/2/16, Esbach, Brandon <Esbachb@tycoelectronics.com>:
A small note about the separate groovy page (I made note of this in the page you put in JV): When you create the page, it cannot have "<%" and "%>". If it does, then it won't work (understandable, a lot of other languages work this way when a separate file used as a source, eg Javascript).
Right, thanks for the addition.
However, this then results in your class being shown in plain text in the saved document (this occurs in B2 and B4, can't test B3 as it's not running on our test environment anymore) - which I would not like to see user's having any view access to. I'm unsure of what to suggest around this, or if it is even a concern. Naturally, if "parseGroovyFromString" would allow the "<%%>" then the page would be protected by default from the user (being correctly assessed as a Groovy page), BUT this is not quite a good solution.
A page with "<%%>" is not be protected by default, the only difference is that the content is not displayed but executed if the page has been saved by a user with programming rights (UWPR). I've added a small trick in the tutorial to prevent a groovy class from being displayed as plain text, but you can't prevent it from being edited by a basic user without using appropriate page rights. http://www.xwiki.org/xwiki/bin/view/DevGuide/GroovyClassHelloWorldTutorial JV.
On Feb 16, 2007, at 12:26 PM, Jean-Vincent Drean wrote:
2007/2/16, Esbach, Brandon <Esbachb@tycoelectronics.com>:
A small note about the separate groovy page (I made note of this in the page you put in JV): When you create the page, it cannot have "<%" and "%>". If it does, then it won't work (understandable, a lot of other languages work this way when a separate file used as a source, eg Javascript).
Right, thanks for the addition.
However, this then results in your class being shown in plain text in the saved document (this occurs in B2 and B4, can't test B3 as it's not running on our test environment anymore) - which I would not like to see user's having any view access to. I'm unsure of what to suggest around this, or if it is even a concern. Naturally, if "parseGroovyFromString" would allow the "<%%>" then the page would be protected by default from the user (being correctly assessed as a Groovy page), BUT this is not quite a good solution.
A page with "<%%>" is not be protected by default, the only difference is that the content is not displayed but executed if the page has been saved by a user with programming rights (UWPR). I've added a small trick in the tutorial to prevent a groovy class from being displayed as plain text, but you can't prevent it from being edited by a basic user without using appropriate page rights. http://www.xwiki.org/xwiki/bin/view/DevGuide/ GroovyClassHelloWorldTutorial
I've added: "Notice the trick of putting a Velocity comment in the Groovy comment so that the code is not parsed by Velocity." Hope this is correct... Thanks -Vincent
Note that whatever you do, if the user has view mode he can access the content using ?xpage=code Ludovic Jean-Vincent Drean a écrit :
2007/2/16, Esbach, Brandon <Esbachb@tycoelectronics.com>:
A small note about the separate groovy page (I made note of this in the page you put in JV): When you create the page, it cannot have "<%" and "%>". If it does, then it won't work (understandable, a lot of other languages work this way when a separate file used as a source, eg Javascript).
Right, thanks for the addition.
However, this then results in your class being shown in plain text in the saved document (this occurs in B2 and B4, can't test B3 as it's not running on our test environment anymore) - which I would not like to see user's having any view access to. I'm unsure of what to suggest around this, or if it is even a concern. Naturally, if "parseGroovyFromString" would allow the "<%%>" then the page would be protected by default from the user (being correctly assessed as a Groovy page), BUT this is not quite a good solution.
A page with "<%%>" is not be protected by default, the only difference is that the content is not displayed but executed if the page has been saved by a user with programming rights (UWPR). I've added a small trick in the tutorial to prevent a groovy class from being displayed as plain text, but you can't prevent it from being edited by a basic user without using appropriate page rights. http://www.xwiki.org/xwiki/bin/view/DevGuide/GroovyClassHelloWorldTutorial
JV.
------------------------------------------------------------------------
-- You receive this message as a subscriber of the xwiki-users@objectweb.org mailing list. To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org For general help: mailto:sympa@objectweb.org?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
-- Ludovic Dubost Blog: http://www.ludovic.org/blog/ XWiki: http://www.xwiki.com Skype: ldubost GTalk: ldubost AIM: nvludo Yahoo: ludovic
participants (4)
-
Esbach, Brandon -
Jean-Vincent Drean -
Ludovic Dubost -
Vincent Massol