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 from a file. All one...
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 ...
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 install...
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 a...
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) book.lock() ...
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 when looking into the sql. ...
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 ...
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...
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...
Recently in a project i used tinymce where i needed to modify the image/link dialog of tinymce. To modify tinymce firstly make it inline/custom plugin means download and paste in javascript folder. To modify image dialog , create a gsp that you want to show in dialog box and paste in [java] ...
Using modules in Geb testing can help to avoid repetition of same code/ sections in Geb test pages. In this blog I want to talk about repeating data structures such as tables and how to avoid this repition by modelling them.In Geb testing if there is some content which is used in multiple pages then we can make its definition reusable by...
We can use PostConstruct with Grails Services and injected Spring Beans. This PostConstruct annotation can be used to annotate a method which needs to be executed after dependency injection to perform any initialization. [code] import javax.annotation.PostConstruct class PostConstructDemoService { @PostConstruct private...