Bhagwat Kumar

Groovy, Grails, Java, J2EE, Open Source, Agile enthusiast , Javascript frameworks, Big Data


SpringOne2GX 2015 – Day 3 : Sessions, Talks and Take Aways

The Day 3, the second last day of the most awaited conference of developers, leaders and organisations working in Java, Spring, Groovy and Grails ecosystem started with a wonderful breakfasted at 7:30 AM in the morning. TO THE NEW Digital, leaders and contributors in Grails, marked their enthusiastic presence on the Day 3 as well and...



SpringOne2GX 2015 – Day 2 : Sessions, Talks and Take Aways

Day 2 of SpringOne2GX, 2015 started on 15th September' 15 at 7:30 AM. The first hour at SpringOne 2GX was Podcast Interviews and some amazing pancakes. Sharp at 8:30, the most awaited and one of the biggest events of the Java and Spring stack community developers started with around 45 sessions planned in 5 slots of 1.5 hours each...



SpringOne2GX 2015 – Day 1 : Demos, Talks, KeyNotes

Day 1 for @SpringOne2GX started at Marriott Marquis Washington, DC, USA today (14th Sept 2015). The day for the conference started at 3PM with registration. Badges for the participants were distributed along with the conference kit and yes a nice T-Shirt for the attendees. Following up next were some great demos of the products and...


Database, Grails

Create game Leaderboard using sqlProjection

Recently I was working on a Facebook game application using Grails 2.0 and Postgres database. The use case was to show the game leaderboard with ranks of the players. Players with same score should be given same rank and next player rank should be incremented rank of last player. Here is the sample data for players and expected result: ...



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



Sorting list with nulls as higher value

I had a list of Strings and wanted to sort them but pay special attention to null values. See the default sorting in demonstration : [groovy] List<String> animals=["Monkey", null, "Ape", null, "Tiger", "Lion"] println animals.sort() ...



uploading multiple files with same name

A good binding feature in grails is that when you have multiple input fields with same name, they are available as a list in params. But this does not hold with html file input fileds. If you have multiple file input fields with same name, params.fieldName will not return a list but the first input field with name fieldName. This is due...



Validating emails, urls and date using Java API

Recently I was looking for a programmatic way for validating data against well known validation e.g. email and date. I have to use them inside custom validator and sometimes in controller/action. Creating Command objects for validating was not suitable in my case(overkilling solution). Writing/looking for regular expression was another...



Playing with call() using Groovy Metaprogramming

In groovy you can use "()" with any groovy object which in turn evaluates to invocation of call() method on that object. For example, the following are valid Groovy statements : [groovy] List myList=["one", "two"] myList() 10() 500 6+5 [name:"Bhagwat", profession:"Software engineer"] name ...


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


Grails, Javascript/Ajax/JQuery

Grails taglib and JavaScript file

We use internationalization feature in grails using message tag in GSP pages. However arbitrary Groovy/Grails (e.g. tags) code can not be used in JavaScript as they are not executed on server side. To overcome this I used the following way : Declare a JSON object in js file or any where else so that this object is global one. Create a...



Externalize and reload grails configuration dynamically

Configuration file plays great role in grails. You can store application specific configuration at one place. One of the grails goodies is that you can externalize configuration file i.e. store them at a location so that it is not packed with the war file. Here is the part of Config.groovy that describes how to specify external...