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