Grails

Grails Console, execute from file.

Grails Console is one of the most useful plugins available, it provides a console to application to which it’s installed. This plugin can be used to test code snippets amazingly fast, debug app, create patches and scripts. And the latest update has made it even more fantastic. Now it has an option to execute code […]

Hitesh Bhatia
Hitesh Bhatia
Read

Grails

User-Role hierarchies in spring security

In most of our applications we are using spring security core plugin for the authentication process. We define some roles in that . Have your ever thought about assigning precedence to the roles. Like, You are having 3 roles defined in your application. i.e. ROLE_SUPER_ADMIN, ROLE_ADMIN ,ROLE_ATTENDEE. While using these roles i.e [java] @Secured([‘ROLE_ATTENDEE’]) def […]

Robin
Robin
Read

Grails

PostgreSQL with Grails

Currently in my Grails project I am using PostgreSQL database so I thought to share my knowledge with everyone. I am using it on Linux operating system. I am mentioning all the steps that I followed to integrate PostgreSQL with Grails . Step 1: Install PostgreSQL on your system To install postgreSql [java] sudo apt-get […]

Gunpreet
Gunpreet
Read

Grails

Log4j: Creating Different Log Files Every Day

To avoid getting log messages in single log file we can create a new log file every day in just one step. This can be done very easily by using DailyRollingFileAppender instead of RollingFileAppender . We just need to add a new Log4J appenders to our configuration file (Config.groovy). In the following example we create […]

Gunpreet
Gunpreet
Read

Grails

Pessimistic locking in Grails

We already know that by default Grails scaffold comes with Optimistic locking and it is achieved by version field. Now lets see how Pessimistic locking is achieved in Grails. Grails has a built in method to acquire lock on object. To acquire a lock we will do something like following [java] Book book = Book.get(1) […]

Grails

Discriminator in Grails inheritance

Whenever I have the use case of inheritance in my Grails application I prefer to have the single table for all the classes, to avoid joins and multiple save statement. But one thing I dont like about this is its class discriminator which have the full class name in it. I dont find it much readable […]

Grails

Inheritance in Grails

In Grails, we can have inheritance with the abstract base class as well as persistent base class. Lets take an example to explain this.(All the classes are in the package com.intelligrape.example) [java] class Blog{ String authorName static constraints = { authorName (nullable:false) } } class TextBlog extends Blog{ String textContent static constraints = { textContent […]

Grails

Cool Spock Ignore/IgnoreRest annotations

While writing a test case, we are generally interested in executing only the one we are working on. With JUnit test case in grails we could say “grails test-app <ClassName>.<currentTestCase>”.  However it doesn’t work with spock specification’s. Spock framework provides multiple cool annotations,  following two annotations can be used to speed up writing/executing test case […]

Amit Jain
Amit Jain
Read

Grails

Appending anchor tag to the url on server side using fragment parameter in Grails

Hi, Recently I had come across one of the cool grails redirect parameter named ‘fragment’ providing cool feature of forming relative link with an anchor tag/name. Generally, we can simply call [groovy]window.location.href=http://yourLink#anchorName[/groovy] It will focus you to the anchor name specified in relative link means scroll the page to the anchored tag who’s anchor name […]

Services