Welcome To Snipplr
Everyone's Recent Groovy Snippets
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
A nice example of utilizing Groovy closures in order to create a when statement in Groovy (http://www.transentia.com.au/flatpress/?x=entry:entry090311-222726).
0
1070
posted 16 years ago by narkisr
This, owner, and delegate:
this : as in Java, this refers to the instance of the enclosing class where a Closure is defined
owner : the enclosing object (this or a surrounding closure)
delegate : by default the same as owner, but changeable.
(htt...
1
1175
posted 16 years ago by narkisr
Groovy ranges works on dates also!
(http://kousenit.wordpress.com/2009/02/02/groovy-groundhogs/)
2
1034
posted 16 years ago by narkisr
Thanx to Guillaume Laforge, who provided this code snippet of Groovy code in a GSP. The snippet below is more or less the same, less the HTML. It will show all future evens and create a eventMap for each event.
0
1255
posted 16 years ago by hansamann
another way to set / create a date using jodatime
download jodatime at http://joda-time.sourceforge.net/
1
879
posted 16 years ago by callmeblessed
how to rollback data on grails' service ....
for myutil --> please look at
0
862
posted 16 years ago by callmeblessed
I need to create all table in InnoDB in my grails application.
you can add this / edit the following code on grails-app/conf/Datasource.groovy
1
1320
posted 16 years ago by callmeblessed
how to render GSP template as String ?
g:render is taglib in gsp (<g:render> ) but you can call it on your controller using g.render().
0
1326
posted 16 years ago by callmeblessed
how to read error message as string instead of complicated codes. usually people using taglib to read error messages. but how to read it in controller/service if you, for example, want to log or render just the message. here is how to do that.
0
1072
posted 16 years ago by callmeblessed
how to call session from grails service (spring service)
0
1102
posted 16 years ago by callmeblessed
how to loop an array / collection / list but with index. instead of using each{} closure, you can use eachWithIndex{} closure
1
889
posted 16 years ago by callmeblessed
Using Groovy you can extend the Sql, DataSet and GroovyResultSet objects present in the language to do simple object mapping similar to iBatis et al. An example of using the code below
/* POGO used in the mapping */
class BranchFax {...
0
1240
posted 16 years ago by kouphax
An example on how to invoke Ant targets which are defined in build.xml.
0
917
posted 16 years ago by narkisr
This example shows how to clone an object from an existing one by using MOP in Groovy, first we find all the writable properties of the cloned object class, secondly we traverse them and on each iteration we copy the value from the current object i...
2
1590
posted 16 years ago by narkisr
Generating MD5 HEX string from either URL or File instance in Groovy (more elegant than the Java version).
1
1503
posted 16 years ago by narkisr
Removes diacritics from file name before adding it to the archive. Archive file name retains diacritics.
0
1158
posted 17 years ago by karelklic
Decorator design pattern implemented in Groovy, two implementation are provided, the first is naive and not general, the second is MOP based and can be used in much more scenarios.
0
1216
posted 17 years ago by narkisr
Mediator design pattern implemented in Groovy (based upon http://www.javacamp.org/designPattern/).
1
1056
posted 17 years ago by narkisr