Sometimes it is required that multiple Grails projects, hosted on a different Grails version, run simultaneously. In this case, while fixing bugs, you are required to run the application after switching the Grails version each time. To handle this scenario, I wrote a utility shell script “runGrails” to use a particular version of Grails while […]
We had a case where we wanted two different applications (run by different users) to be able to read and write from the same file system. This is how we solved this problem: Create a group which these users will belong to :[shell]groupadd GROUP_NAME[/shell] Edit user1 and user2 to be a member of this group:[shell] […]
This post might help you if you want to display alert messages without using tradition javascript (irritating) alert. To achieve this you need jQuery for your frontend UI. Below is the javascript method (code snapshot) which displays your message for 5 seconds. And then fades out automatically. function displayAlertMessage(message) { var timeOut = 5 jQuery(‘#messageBox’).text(message).fadeIn() […]
I have been facing a problem of running configurable number of instances of the same job to consume the traffic that was varying over time. In order to dynamically create an instance of a job and run it immediately, I googled and found some interesting facts like each trigger is fired with a new instance […]
following are two methods for getting parameters from GSP in form of list only:- even if the variable has only one value, it will be recieved as a list and not as “String”. List<String> myList = params.list(‘variableName’) List<String> myList = [params.variableName].flatten() ~~Niraj Kumar~~ niraj@intelligrape.com http://www.tothenew.com
Hey, Recently, I need to show some printing stuff using window.open() method of JavaScript. I got stuck when the implementation demands sending POST call to the server for generating the print view. I googled a lot and found few JavaScript code snippets that provides some workaround for doing this stuff. Finally, I found some cool […]
Hi Friends, I needed to validate password for certain conditions. As per the requirements, any valid must password must pass the following conditions: Minimum of 7 characters Must have numbers and letters Must have at least a one special characters- “!,@,#,$,%,&,*,(,),+” I wrote the following method to meet the requirements: import java.util.regex.* boolean validatePassword(String password) […]
Hi all, Here I am giving a brief introduction about unit testing of services in grails. I will explain it with the help of a simple example. We have a domain class named: Item Two services : UtilService and ItemService Code of UtilService.groovy // class UtilService code class UtilService { boolean transactional = true Integer […]
Following is an example of unidirectional one-to-many relationship: class Employee { String name static hasMany = [roles: Role] } class Role { String name } How can we find all the employees with a particular role – “Grails Developer”? Role role = Role.findByName(“Grails Developer”) One way of doing this can be: Employee.list().findAll{role in it.roles} This […]
In one of the recent projects, we had to set up a system where emails for different purposes (i.e registration, error reporting etc.) were to be sent out from different email accounts. We were using the Grails Mail plugin which does not provide a clear way to set-up or configure multiple email addresses. With the […]
Through my blog, I will discuss about sending JSON objects with ajax request using JQuery. We have number of functions in jQuery to kick-off an ajax request. But for sending JSON objects along with the request, I chose jQuer.ajax(). It takes various parameters url, type, data, dataType, beforeSend etc. Its API can be found here. […]
Recently i worked upon redirecting all the log related to a specified package in my project to a specific file. It seem very helpful as it provide precise context about run of your application and make it easier to debug as compare to low level debugging method such as println. Here we can also disable […]