Grails

Enhance HttpServletRequest using metaprogramming

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.

Bhagwat Kumar
Bhagwat Kumar
Read

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 Completion) […]

Kushal Likhi
Kushal Likhi
Read

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 […]

Amit Kumar
Amit Kumar
Read

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 […]

Vivek Sachdeva
Vivek Sachdeva
Read

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 many to many relationships […]

Sachin Verma
Sachin Verma
Read

GrailsProduct EngineeringSoftware development

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 […]

Vishal Sahu
Vishal Sahu
Read

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 & […]

Mohit Garg
Mohit Garg
Read

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 […]

Tarun Pareek
Tarun Pareek
Read

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 […]

Hitesh Bhatia
Hitesh Bhatia
Read
Services