Hi, In the previous blog we saw how to post status update on Twitter using Twitter4j library. In the same project i had the requirement to show Twitter home timeline inside our application. I used the same java wrapper library to retrieve tweets from the user twitter account. In this blog we will see how […]
Groovy is a dynamic language. We can’t check any typo error, method or property missing error at compile time. To check typo error, method or property missing at compile time, Groovy 2.0 introduces new features named as Static Type Checking which helps to check errors at compile time. To use static type checker in groovy […]
In one of my recent project, i want to profile method execution time. I have used Spring AOP to profile method execution time. It’s very easy to implement AOP profiling in grails 1. Suppose we have below mentioned service class, we want to log execution time of method saveDataStudent,saveDataUpdated methods in service class. We need […]
In my previous blog, i have mentioned how to integrate spring cache plugin in grails. In this blog we will see how we can use different attributes of cache. Different attributes of cache :- maxElementsInMemory- How many elements you can store in cache overflowToDisk-The attribute overflowToDisk is true, meaning that whenever the maximum number of […]
In one of my recent project, i want to cache method output. For implementing method level cache, i have used spring cache. For implement Spring cache, we can use grails cache plugin. It’s very easy to integrate cache plugin with grails. 1. Add following plugin dependency in BuildConfig.groovy. [groovy]compile ":springcache:1.3.1" [/groovy] 2. We need to […]
In my recent project there was a use case where I had to query domain’s hasMany but relationship was not with any domain class but rather String type. Consider example [java] class Blog { static hasMany = [tags: String] } [/java] Now to find all the blogs with tag “grails” , our normal way of […]
Hi, There could be cases where we would need to inject some methods or properties in all GSP pages. As we know that the GSP pages extends GroovyPage class, hence injecting properties/methods in GroovyPage class can solve out purpose. Example: Lets add appVersion property and a method to provide logo link irrespective […]
Blog teach you : how to enhance http request object by adding helper methods using groovy meta programming. The blog contains most commonly methods to request object such as isAjax, siteUrl, isMobileBrowser, remoteIPAddress etc. Once they are injected from Bootstrap.groovy init closure, the new methods are available in controllers and filters. Blog shows some use cases where these helper methods has been used successfully.
Hi, Groovy took another leap ahead in the methodology of defining Strings by providing us with “dollar-slashy” strings which further minimized the need of escaping any special character as compared to simple “slashy” Strings. In the Groovy ver:1.8+ you can define Strings as follows: [java] //A dollar-slashy string String message = $/Hi! I […]