Hello Friends, I was using Jsecurity plugin in my project. There was an action in a controller which needed logged in user information and I was finding it difficult to write an integration test for the same. Then Brent Fisher shared the following code which worked nicely for both services and controllers: import org.jsecurity.SecurityUtils import […]
In our current project on Grails we faced a problem where we need to change the schedule of quartz job programmatically. The timeout value is read from the database. After doing some googling and digging mailing lists we found the following way- class MyJob{ static triggers = { simple name: ‘mySimpleTrigger’, group: ‘mySimpleTriggerGroup’ } def […]
I recently came across a way in Groovy to define a class which can have dynamic getters and setters and properties can be added on the fly. The following code creates a class “MyExpandableClass” and defines two methods in the “getProperty and setProperty”. If we define these two methods in a groovy class, then calls […]
Many a times, it is required to inject a Spring Bean into a Grails artefact. It has happened a few times with us in our projects that we needed to inject a TagLib bean in the service layer for code re-use for sending out e-mails. This is how we achieved it MyService implements org.springframework.context.ApplicationContext Import […]
Just thought I would share with you few tips or key points we should remember while writing integration test cases: 1. Flush and clear the session object for every single test case for example class FooTests extends GroovyTestCase { def sessionFactory void setUp() { sessionFactory.currentSession.flush() sessionFactory.currentSession.clear() } } 2. Drop and create the test database […]
Hi Friends, I was working on the financial application, where the user doesn’t want to select merchant provider while feeding in credit card details and yet we needed to know the merchant provider. Following is the code that helped: function getMerchantProvider(cardNo){ //cardNo is the credit card number var cards = new Array(); cards [0] […]
In my current project, I used ajax to fetch data from the server to provide experience like Desktop Application. I wanted to automatically show an indicator when an AJAX request is ongoing, and hide it when there is no such request. So I found the following solution for both the Prototype library and the JQuery […]
Let us have a look at the simple javascript code, that can be used to add hotkeys to our web application. I tried using jquery hotkeys plugin and two more plugins, but they didn’t work for me. So I ended up handling the keydown event of my own. var isAlt = false; document.onkeyup = function(e) […]
In one of my project assignments I needed to insert large number of records into the database. I had to read the objects from an external source. Once I read all of the objects into a List, I iterated the list to save each one of them individually. In the beginning the process carried on […]
In this blog Reverse Url Mappings has been used to generate the URL ending with .html, given controller and action names.
Note: Months are from 0 to 11. Hence the 7th month is “August” Calendar calendar = GregorianCalendar.instance calendar.set(2009, 7, 21) println “Last Day of a Month: ${calendar.getActualMaximum(GregorianCalendar.DAY_OF_MONTH)}” Cheers!!! ~Chandan Luthra~ chandan@intelligrape.com www.intelligrape.com
Grails : Caching using cron jobs i.e using quartz plugin. As with grails 1.1.1 plugin springcache plugin didn’t work.