AWS

Groovy : Find Index of Element in Map

Groovier way of finding index of element from Map. It can be obtained with findIndexOf Method, which accepts closure as argument. [groovy] Map map=["groovy":1,"grails":2,"index":3,"element":4] assert 3 == map.findIndexOf{it.key=="element"} assert 0...

by Hitesh Bhatia
Tag: Grails
10-Nov-2011

Grails

Criteria Query with Left Outer Join

In Grails app development, when using criteria queries, we often find cases for Outer joins. Lets take an example. We have two domain classes with us: [java] class Blog { String title String content static hasMany = [comments: Comment] static constraints = { } } [/java] and [java] class Comment { ...

by Himanshu Seth
Tag: Grails
01-Nov-2011

Grails

Grails bindData to collections

Recently, I was stuck with a scenario where I was trying to bind a list of objects in my controller. While trying the way as suggested in the grails docs I was getting some weird IndexOutOfBoundException. Luckily I found a good solution on the grails mailing list:...

by Mohd Farid
Tag: Grails
24-Oct-2011

Grails

Grails: Get table name mapped to a domain

Hi guys, Recently while working on a project, I needed to get the table names associated with a particular domain as I needed to perform complex join operations on a particular table. The database that my team was working on was a legacy database. The domains that were created were mapped to particular tables to provide backward...

by Roni C Thomas
Tag: Grails
19-Aug-2011

Grails

Grails: Dynamically create instance of a POGO class

Hi guys, Recently on a project, I was creating a number of command objects to accept incoming parameters from a POST call from an iPhone with which I needed to sync data. I created a parent class for all command object classes to accept the common properties and created individual command object classes to accept any additional...

by Roni C Thomas
Tag: Grails
15-Jun-2011

Grails

Grails domain class and DDL sql file using schema-export

While debugging a domain and its database schema I found an interesting grails command line Gant script: schema-export. One of the great Grails command line Gant script to generate SQL scripts(DDL) which is executed against your database to model your grails domain. You can control the environment and the output file to generate the...

by Bhagwat Kumar
Tag: Grails
04-May-2011

Grails

A use case of Bitwise AND

Recently, I used bitwise Anding in my grails project. I am sharing the approach that we followed by means of an example. Suppose we have a domain class Person which can have multiple attributes like Smart, Intelligent, Talkative etc. What sort of relationship comes to our mind when we see this? I believe the obvious answer would...

by Mohd Farid
Tag: Grails
15-Apr-2011

Grails

Truncate Table ? executeUpdate OR createSQLQuery

In one of the modules that I was working on , I needed to delete the previous data from a table then load up the data into those tables again and then manipulate code through the 'id's' on those tables. So this is what I was doing ... [groovy] Event.executeUpdate('delete from Event') EventInstance.executeUpdate('delete from...

by Manoj Mohan
Tag: Grails
14-Apr-2011

Grails

ISO-8859 Based URL Encoding in Grails

The web application we are developing at the moment interacts with quite a few third party services via REST calls. Most of the third party services use UTF-8 encoding and there was no issues with using the URLCodec, that grails provides out of the box. However, one of the applications our application interacts with, was using ISO-8859-1...

by Vivek Krishna
Tag: Grails
11-Apr-2011

Grails

Handling Instance Based Security

In my current project, we were required to implement Instance Based Security. The idea was to find a clean solution separate from the main business logic of the application. We took a clue from the Spring Security Plugin to use the Annotations to do our job. All we wanted to do was to develop annotations for actions, which could help to...

by Imran Mir
Tag: Grails
06-Apr-2011

Grails

Remote-pagination : support for javascript events added

Hi Friends, I have released the version 0.2.5 of Remote-Pagination, which now provides the support for all the events as supported by grails tags like remote-link.  Events supported are listed below : onSuccess  - The javascript function to call if successful onFailure  - The javascript function to call if the call failed ...

by Amit Jain
Tag: Grails
14-Mar-2011

Grails

Using TagLib to avoid changes due to change in URLMappings

Recently, I used Taglib to centralize the effect of URL mapping related changes of my grails application. [java] def userPageLink = {attrs, body -> def user = User.read(attrs.id) out << g.link(controller: 'user', action: 'show', params: [name: user.name]) {body()} } [/java] So wherever I need a link to user page, I...

by Mohd Farid
Tag: Grails
14-Feb-2011