Groovy and idioms questions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Groovy and idioms questions

Jacques Le Roux
Administrator
Hi All,

I suppose, from this snippet taken from the 1st line of Revision: 664118

-security = request.getAttribute("security");
-delegator = request.getAttribute("delegator");
-
-if(security.hasEntityPermission("CATALOG", "_VIEW", session)) {
-    context.hasPermission = Boolean.TRUE;
-} else {
-    context.hasPermission = Boolean.FALSE;
-}
+context.hasPermission = security.hasEntityPermission("CATALOG", "_VIEW", session);

that Groovy provides the variables security and delegator without having to get them out of request (I was surprised, so I tested, and it works ;o). Is there a list somewhere of all alike variables (I searched a bit but it's far too late now) ?

BTW, I wonder if you (OFBiz developpers/contributors) would like to share idioms you use either in Java, Freemarker and now Groovy. We could create a Wiki page for that (under Best practices I guess). This could be interesting (mostly for Groovy which is much creative) for 2 reasons : to grow our personnal knowledge without having to refer to code (where we know there is this stuff we search for, somewhere we saw before) and homogenize our way of coding which should be fruitful for everybody (after all, we share the code). Sorry for the long sentence :o)

If some of you are interested just let me know and I will create this page and a new thread.

Thanks

Jacques
Reply | Threaded
Open this post in threaded view
|

Re: Groovy and idioms questions

Adrian Crum-2
Some of the code that was replaced was from the JPublish days - before the screen widgets. Now the screen widgets have those objects in the screen rendering context.

Check out ScreenRenderer.java populateBasicContext and populateContextForRequest methods.

-Adrian

--- On Sat, 6/7/08, Jacques Le Roux <[hidden email]> wrote:
From: Jacques Le Roux <[hidden email]>
Subject: Groovy and idioms questions
To: [hidden email]
Date: Saturday, June 7, 2008, 4:44 PM

Hi All,

I suppose, from this snippet taken from the 1st line of Revision: 664118

-security = request.getAttribute("security");
-delegator = request.getAttribute("delegator");
-
-if(security.hasEntityPermission("CATALOG", "_VIEW",
session)) {
-    context.hasPermission = Boolean.TRUE;
-} else {
-    context.hasPermission = Boolean.FALSE;
-}
+context.hasPermission = security.hasEntityPermission("CATALOG",
"_VIEW", session);

that Groovy provides the variables security and delegator without having to get
them out of request (I was surprised, so I tested, and it works ;o). Is there a
list somewhere of all alike variables (I searched a bit but it's far too
late now) ?

BTW, I wonder if you (OFBiz developpers/contributors) would like to share
idioms you use either in Java, Freemarker and now Groovy. We could create a
Wiki page for that (under Best practices I guess). This could be interesting
(mostly for Groovy which is much creative) for 2 reasons : to grow our
personnal knowledge without having to refer to code (where we know there is
this stuff we search for, somewhere we saw before) and homogenize our way of
coding which should be fruitful for everybody (after all, we share the code).
Sorry for the long sentence :o)

If some of you are interested just let me know and I will create this page and
a new thread.

Thanks

Jacques


     
Reply | Threaded
Open this post in threaded view
|

Re: Groovy and idioms questions

Jacques Le Roux
Administrator
Thanks Adrian,

I was a very beginner during the JPublish era

Jacques

From: "Adrian Crum" <[hidden email]>

> Some of the code that was replaced was from the JPublish days - before the screen widgets. Now the screen widgets have those
> objects in the screen rendering context.
>
> Check out ScreenRenderer.java populateBasicContext and populateContextForRequest methods.
>
> -Adrian
>
> --- On Sat, 6/7/08, Jacques Le Roux &lt;[hidden email]&gt; wrote:
> From: Jacques Le Roux &lt;[hidden email]&gt;
> Subject: Groovy and idioms questions
> To: [hidden email]
> Date: Saturday, June 7, 2008, 4:44 PM
>
> Hi All,
>
> I suppose, from this snippet taken from the 1st line of Revision: 664118
>
> -security = request.getAttribute("security");
> -delegator = request.getAttribute("delegator");
> -
> -if(security.hasEntityPermission("CATALOG", "_VIEW",
> session)) {
> -    context.hasPermission = Boolean.TRUE;
> -} else {
> -    context.hasPermission = Boolean.FALSE;
> -}
> +context.hasPermission = security.hasEntityPermission("CATALOG",
> "_VIEW", session);
>
> that Groovy provides the variables security and delegator without having to get
> them out of request (I was surprised, so I tested, and it works ;o). Is there a
> list somewhere of all alike variables (I searched a bit but it's far too
> late now) ?
>
> BTW, I wonder if you (OFBiz developpers/contributors) would like to share
> idioms you use either in Java, Freemarker and now Groovy. We could create a
> Wiki page for that (under Best practices I guess). This could be interesting
> (mostly for Groovy which is much creative) for 2 reasons : to grow our
> personnal knowledge without having to refer to code (where we know there is
> this stuff we search for, somewhere we saw before) and homogenize our way of
> coding which should be fruitful for everybody (after all, we share the code).
> Sorry for the long sentence :o)
>
> If some of you are interested just let me know and I will create this page and
> a new thread.
>
> Thanks
>
> Jacques
>
>
>