TO THE NEW Blog PAGES

Grails

Script for Running Grails Projects of Different Versions Simultaneously

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 […]

Technology

How to Set-up shared folder/repository between two or more users on Linux

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] […]

Technology

jQuery Alert Message without using traditional javascript alert-box.

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() […]

Salil
Salil
Read

Grails

Running multiple instances of a quartz job dynamically

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 […]

Grails

Getting params attribute as list()

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

niraj
niraj
Read

Technology

How to send a POST request in window.open() function of JavaScript.

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 […]

Grails

Password validation with certain conditions

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) […]

Grails

Unit-Tests : Getting started with Service Unit Test

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 […]

Grails

Grails criteria query example for unidirectional one-to-many relationships

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 […]

Grails

Configuring multiple senders in Grails Mail plugin

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 […]

Technology

JQuery: Send JSON Objects with an Ajax Request

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. […]

Grails

Configuring Log4J for logging level specific logs of different packages into file using appenders

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 […]