Accessing Groovy function from velocity

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing Groovy function from velocity

Esbach, Brandon
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



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Accessing Groovy function from velocity

Jean-Vincent Drean
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 <[hidden email]>:

>
>
>
> 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 [hidden email]
> mailing list.
> To unsubscribe:
> mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Accessing Groovy function from velocity

vmassol
Administrator
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 <[hidden email]>:
>>
>>
>>
>> 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-
>> [hidden email]
>> mailing list.
>> To unsubscribe:
>> mailto:[hidden email]
>> For general help: mailto:[hidden email]?subject=help
>> ObjectWeb mailing lists service home page: http://
>> www.objectweb.org/wws
>>
>>
>
>
> --
> You receive this message as a subscriber of the xwiki-
> [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/ 
> wws



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Accessing Groovy function from velocity

Esbach, Brandon
Ahh, nice job!
Many thanks, it's a lot clearer now!

-----Original Message-----
From: Vincent Massol [mailto:[hidden email]]
Sent: 16 February 2007 08:06
To: [hidden email]
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 <[hidden email]>:
>>
>>
>>
>> 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-
>> [hidden email] mailing list.
>> To unsubscribe:
>> mailto:[hidden email]
>> For general help: mailto:[hidden email]?subject=help
>> ObjectWeb mailing lists service home page: http://
>> www.objectweb.org/wws
>>
>>
>
>
> --
> You receive this message as a subscriber of the xwiki-
> [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/ 
> wws




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Accessing Groovy function from velocity

Esbach, Brandon
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:[hidden email]]
Sent: 16 February 2007 09:32
To: [hidden email]
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:[hidden email]]
Sent: 16 February 2007 08:06
To: [hidden email]
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 <[hidden email]>:
>>
>>
>>
>> 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-
>> [hidden email] mailing list.
>> To unsubscribe:
>> mailto:[hidden email]
>> For general help: mailto:[hidden email]?subject=help
>> ObjectWeb mailing lists service home page: http://
>> www.objectweb.org/wws
>>
>>
>
>
> --
> You receive this message as a subscriber of the xwiki-
> [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/ 
> wws





--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Accessing Groovy function from velocity

Jean-Vincent Drean
2007/2/16, Esbach, Brandon <[hidden email]>:
> 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 [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Accessing Groovy function from velocity

vmassol
Administrator

On Feb 16, 2007, at 12:26 PM, Jean-Vincent Drean wrote:

> 2007/2/16, Esbach, Brandon <[hidden email]>:
>> 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




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Accessing Groovy function from velocity

Ludovic Dubost
In reply to this post by Jean-Vincent Drean

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 <[hidden email]>:
>> 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 [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?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




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws