There's been a while since I was waiting something like this landing in the Groovy scene. Why couldn't we have a Javascript "compiler" to use it in the views as well?
Although Grooscript still needs time to be mature it's really promising. I have played with it a little bit and it's really funny the things you can do in Groovy. The most important feature in version 0.1 is that you can call native javascript inside your methods. The syntax to do it is the following:
@org.grooscript.GsNative def myMethod(parameter){/* //Javascript Code Here */}
This syntax has been chosen among others mainly because the lack of native method support in Groovy. We couldn't have used the word 'native' as GWT does when invoking javascript native methods.
By the time I'm writing this entry I have found one issue in the native support in Grooscript, and it seems that the workaround is pretty easy, you only need to add a dummy method at the end of your script to make the native support works.
@org.grooscript.GsNative def myMethod(parameter){/* alert(parameter); */} @org.grooscript.GsNative def dummy(){/**/}
Because I really liked the project I started creating a Grails plugin to be able to use it any Grails project. It is not available yet in the Grails repository, but I guess it will be eventually. You can clone it, package it and install it in your Grails application, the code is at github.
The plugin enables you to declare Groovy scripts as static resources and compile those scripts to Javascript code.
Groovy files must have the suffix '.gs'. I still don´t know why files with '.groovy' suffix can´t be 'watched' (Grails doesn´t see any changes made to that files). In the meanwhile I opened an issue at JIRA (The more votes the faster it could be resolved :-) )
You must declare the dependency of the 'grooscript' module in those modules you're declaring any groovy scripts (I also have added here the jquery dependecy because I use it in the example).
modules = { myGroovyFiles{ dependsOn 'jquery' dependsOn 'grooscript' resource url:'js/gs/GrooscriptNative.gs' } }
In order to proof the native support of Grooscript I did a really simple example. I made a script that changes the Grails logo in your Grails application for the Grooscript logo. Here's the code of the GrooscriptNative.groovy
import org.grooscript.asts.* class GrooscriptNative{ @GsNative def changeImage(selector,image){/* $(selector).attr("src",image.url); */} /* Workaround for an issue */ @GsNative def dummy(){/* */} } class ImageHolder{ String url } def selector = "#grailsLogo a img" def image = new ImageHolder(url:"http://grooscript.org/img/logo.png") new GrooscriptNative().changeImage(selector,image)If you've installed the plugin properly, declared the ".gs" file in the resources file and on running the application you opened the browser you should see the following:
Cool!! isn't it?
You can get Grooscript from its site or getting the jar adding the public sonatype repository as an extra maven repository to your project.
Ecorptrainings.com provides GROOVY in hyderabad with best faculties on real time projects. We give the best online trainingamong the GROOVY in Hyderabad. Classroom Training in Hyderabad India
ReplyDeleteExcellent blog has been given.very well explanation about plugin enables.
ReplyDeletethanks for sharing this blog.
oracle fusion procurement online training
Oracle fusion financials online training institute we have our branch over all the india.
ReplyDeleteOracle Fusion Cloud HCM Online Training in Hyderabad, Bangalore, Delhi, Chennai, Kolkata, Pune, Mumbai, Ahmedabad, Gurgon, Noida, India, Dubai, UAE, USA, Kuwait, UK, Singapore, Saudi Arabia, Canada, Oracle Fusion HCM Online Trainings
Oracle fusion Financials Online Training
Oracle Fusion Financials online Training
thanq very much for sharing
ReplyDeleteLearn Oracle Fusion Financials Online training from igofusion classroom coaching
All given info was wonderful and it's very helpful for everyone. I read your post is very nice thank you.
ReplyDeleteWe Have Top Rated CALFRE Search Engine to search about all different courses in Al Karama, Dubai Locations. For Example Search a particular course like Oracle ASCP Training in Location Dubai Know More Click Here
Hi, Thanks for posting a great information of the your blog.
ReplyDeleteDOT NET Training Institutes in Ameerpet
I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work.
ReplyDeleteOracle Project Accounting Training in Hyderabad
Nice information. I was searching for the same. It helped me a lot and saved my time.
ReplyDeleteOracle Fusion SCM Training in Hyderabad
It's Incredibly grand. Really very helpful article , Thank you for sharing
ReplyDeleteWorkday Online Training
Web Development Company in chennai
ReplyDeleteXmedia Solution About us
Xmedia Solution infrastructure
Xmedia Solution Career
aşk kitapları
ReplyDeletetiktok takipçi satın al
instagram beğeni satın al
youtube abone satın al
twitter takipçi satın al
tiktok beğeni satın al
tiktok izlenme satın al
twitter takipçi satın al
tiktok takipçi satın al
youtube abone satın al
tiktok beğeni satın al
instagram beğeni satın al
trend topic satın al
trend topic satın al
youtube abone satın al
takipçi satın al
beğeni satın al
tiktok izlenme satın al
sms onay
youtube izlenme satın al
tiktok beğeni satın al
sms onay
sms onay
perde modelleri
instagram takipçi satın al
takipçi satın al
tiktok jeton hilesi
instagram takipçi satın al pubg uc satın al
sultanbet
marsbahis
betboo
betboo
betboo
Thanks for sharing such a wonderful information from this post. We are providing the best services click on below links to visit our website.
ReplyDeleteOracle Fusion HCM Training
Workday Training
Okta Training
Palo Alto Training
Adobe Analytics Training
thanks for sharing a nice post keep posting https://snowflakemasters.in/
ReplyDeleteperde modelleri
ReplyDeletesms onay
mobil ödeme bozdurma
nft nasıl alınır
Ankara evden eve nakliyat
trafik sigortasi
Dedektor
web sitesi kurma
ASK ROMANLARİ
This is the good website and it's a fantastic website Your contribution is greatly appreciated https://sclinbio.com
ReplyDeleteNice post! Thank you.
ReplyDeletemedical coding course in hyderabad
Great post! Thank you
ReplyDeletemedical coding course in hyderabad
medical coding course in hyderabad
ReplyDeletegreat information!
medical coding course in hyderabad
ReplyDeleteGood post! Thank you.
good post!
ReplyDeletemedical coding course in hyderabad