You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Jacques Le Roux <ja...@les7arts.com> on 2008/06/08 01:44:56 UTC

Groovy and idioms questions

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

Re: Groovy and idioms questions

Posted by Jacques Le Roux <ja...@les7arts.com>.
Thanks Adrian,

I was a very beginner during the JPublish era

Jacques

From: "Adrian Crum" <ad...@yahoo.com>
> 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;jacques.le.roux@les7arts.com&gt; wrote:
> From: Jacques Le Roux &lt;jacques.le.roux@les7arts.com&gt;
> Subject: Groovy and idioms questions
> To: dev@ofbiz.apache.org
> 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
>
>
> 


Re: Groovy and idioms questions

Posted by Adrian Crum <ad...@yahoo.com>.
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;jacques.le.roux@les7arts.com&gt; wrote:
From: Jacques Le Roux &lt;jacques.le.roux@les7arts.com&gt;
Subject: Groovy and idioms questions
To: dev@ofbiz.apache.org
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