Grails

How to implement AOP Profiling in Grails application

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...

by Mohit Garg
Tag: Grails
25-Sep-2012

Grails

Attributes of Spring Cache

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...

by Mohit Garg
Tag: Grails
25-Sep-2012

Grails

How to integrate Spring cache plugin with Grails

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...

by Mohit Garg
Tag: Grails
25-Sep-2012

Grails

Enhance HttpServletRequest using metaprogramming

Most of the times we use request.getHeader("user-agent") to get the client browser user-agent details inside the Grails Filters or Controllers. User-agent is one of the examples. There are so many such methods e.g. method for checking whether the request was an ajax call, getting IP address of the client machine, checking whether the...

by Bhagwat Kumar
Tag: Grails
25-Sep-2012

Grails

GDSL Awesomeness – Introduction to GDSL in IntelliJ Idea

One of the disadvantage of using meta-programming and DSL is that we don't get auto-completes in Our IDE. Hence IntelliJ provided us with an awesome and intelligent toolkit to handle dynamic properties and methods when writing code in groovy. In IntelliJ IDEA we can write GDSL Files in order to give us the auto-completes(code...

by Kushal Likhi
Tag: Grails
25-Sep-2012

Grails

Grails pageProperty tag

In my current project, I tried to call a javascript function on onload event of body tag of gsp page: [html] ... [/html] But this onload event was not fired, because Grails picks the body tag from layout and not from the view. So I added the following line in body tag of my layout [html] ... [/html] In above example...

by Amit Kumar
Tag: Grails
24-Sep-2012

Grails

Bootstrap using faker plugin

Every now and then we have to bootstrap data in our application. It takes lot of time thinking what name to give, what description to add and other stuff. To overcome this, we can use faker plugin which can generate random tokens as per your need. To use this, add following in BuildConfig.groovy [java] compile...

by Vivek Sachdeva
Tag: Grails
23-Sep-2012

Grails

Extract correct class from hibernate object wrapped with javassist

Hi, Some times when we access domain objects of collections in one to many or many to many relationships, we get Hibernate class wrapped with javassist, basically hibernate wraps all loaded objects with javassist after loading(lazy loading case) them . So if  we call  class.name on the members of collections in one to many or...

by Sachin Verma
Tag: Grails
21-Sep-2012

Grails, Product Engineering

Copy Files/Folders from one location to another in Groovy

It is normally difficult to copy file/folders from one location to another. In my recent Grails Development project, i successfully achieved this. I had to copy files/folders from one location to another on file system. I searched about it and came across a cool method to copy files or directories from one location to another. We can...

by Vishal Sahu
Tag: Grails
21-Sep-2012

Grails

Implement Ajax call in Grails web-flow

In one of my recent project, i want to use grails web-flow with ajax call. It's very easy to implement the web-flow with ajax call. Grails web-flow always track the actions on the basis of eventId & flow execution key. So, to implement ajax call in web-flow, we have to pass the event id & flow execution key. 1. Let us assume,...

by Mohit Garg
Tag: Grails
16-Sep-2012

Grails

Mapping duplicate domain class name having different packages using autoImport in Grails

Hi, Recently one of my friend asked me whether there is a mechanism in grails to handle the use-case where we have different packages but having same domain name. Here we are having duplicate domain class names in different package and by default the domain classes are auto-imported in HQL queries which doesn't required to specify...

by Tarun Pareek
Tag: Grails
14-Sep-2012

Grails

Grails : login fails on upgrading shiro plugin.

We are in the process of upgrading our pre 2.0 Grails app to version 2.1.0. This propelled us to update many of the used plugins. One of them was Shiro plugin. We upgraded it from 1.0.1 to 1.1.4. On upgrading the plugin our login attempts were consistently failing, the reason being, this version uses Sha512Hash and with older version...

by Hitesh Bhatia
Tag: Grails
09-Sep-2012