how to pass groovy variables to widget screen?

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

how to pass groovy variables to widget screen?

aradmoney
Hi All,
I am reading some of tutorial about widget screen, but it is written with
beanshell.

with beanshell,  if i put a line

*String hello = "world";
context.put("hello", hello);*

in the *helloworld*.*bsh* file.

then I can retrieve it in widget screen by calling it in action tag
*<actions>
<script
location="component://hello/webapp/hello/WEB-INF/actions/hello/helloworld.bsh"/>
</actions>*

and  access it by using *${hello}*,then i will have "*world*".

anyone know how do I do the same thing with *groovy*?
Thank you
Reply | Threaded
Open this post in threaded view
|

Re: how to pass groovy variables to widget screen?

Deepak Dixit-2
You use same with groovy, rename helloworld.bsh to helloworld.groovy

helloworld.groovy
{code}

hello="world";
context.hello = hello;

{code}

include groovy file in action tag.

then you can use using ${hello} and in you are using form widget then you can use the from-field attribute.


Thanks & Regards
--
Deepak Dixit
HotWax Media Pvt. Ltd.
www.hotwaxmedia.com
Contact :- +91-98267-54548
Skype  :- deepakdixit

On Feb 7, 2013, at 5:50 AM, John Smith wrote:

> Hi All,
> I am reading some of tutorial about widget screen, but it is written with
> beanshell.
>
> with beanshell,  if i put a line
>
> *String hello = "world";
> context.put("hello", hello);*
>
> in the *helloworld*.*bsh* file.
>
> then I can retrieve it in widget screen by calling it in action tag
> *<actions>
> <script
> location="component://hello/webapp/hello/WEB-INF/actions/hello/helloworld.bsh"/>
> </actions>*
>
> and  access it by using *${hello}*,then i will have "*world*".
>
> anyone know how do I do the same thing with *groovy*?
> Thank you


smime.p7s (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: how to pass groovy variables to widget screen?

aradmoney
Thanks Deepak,

Do you know how to make it a global variable(globalContext)?

Thanks in advance.

John

On Thu, Feb 7, 2013 at 3:40 PM, Deepak Dixit
<[hidden email]>wrote:

> You use same with groovy, rename helloworld.bsh to helloworld.groovy
>
> helloworld.groovy
> {code}
>
> hello="world";
> context.hello = hello;
>
> {code}
>
> include groovy file in action tag.
>
> then you can use using ${hello} and in you are using form widget then you
> can use the from-field attribute.
>
>
> Thanks & Regards
> --
> Deepak Dixit
> HotWax Media Pvt. Ltd.
> www.hotwaxmedia.com
> Contact :- +91-98267-54548
> Skype  :- deepakdixit
>
> On Feb 7, 2013, at 5:50 AM, John Smith wrote:
>
> > Hi All,
> > I am reading some of tutorial about widget screen, but it is written with
> > beanshell.
> >
> > with beanshell,  if i put a line
> >
> > *String hello = "world";
> > context.put("hello", hello);*
> >
> > in the *helloworld*.*bsh* file.
> >
> > then I can retrieve it in widget screen by calling it in action tag
> > *<actions>
> > <script
> >
> location="component://hello/webapp/hello/WEB-INF/actions/hello/helloworld.bsh"/>
> > </actions>*
> >
> > and  access it by using *${hello}*,then i will have "*world*".
> >
> > anyone know how do I do the same thing with *groovy*?
> > Thank you
>
>
Reply | Threaded
Open this post in threaded view
|

Re: how to pass groovy variables to widget screen?

Vikas Mayur-2
In reply to this post by Deepak Dixit-2
Btw, Use camel case pattern for naming the groovy file - tips and tricks - https://cwiki.apache.org/OFBIZ/tips-tricks-while-working-with-groovy.html

Regards
Vikas

On Feb 7, 2013, at 10:10 AM, Deepak Dixit wrote:

> You use same with groovy, rename helloworld.bsh to helloworld.groovy
>
> helloworld.groovy
> {code}
>
> hello="world";
> context.hello = hello;
>
> {code}
>
> include groovy file in action tag.
>
> then you can use using ${hello} and in you are using form widget then you can use the from-field attribute.
>
>
> Thanks & Regards
> --
> Deepak Dixit
> HotWax Media Pvt. Ltd.
> www.hotwaxmedia.com
> Contact :- +91-98267-54548
> Skype  :- deepakdixit
>
> On Feb 7, 2013, at 5:50 AM, John Smith wrote:
>
>> Hi All,
>> I am reading some of tutorial about widget screen, but it is written with
>> beanshell.
>>
>> with beanshell,  if i put a line
>>
>> *String hello = "world";
>> context.put("hello", hello);*
>>
>> in the *helloworld*.*bsh* file.
>>
>> then I can retrieve it in widget screen by calling it in action tag
>> *<actions>
>> <script
>> location="component://hello/webapp/hello/WEB-INF/actions/hello/helloworld.bsh"/>
>> </actions>*
>>
>> and  access it by using *${hello}*,then i will have "*world*".
>>
>> anyone know how do I do the same thing with *groovy*?
>> Thank you
>


smime.p7s (6K) Download Attachment