Hi Friends, I have released version 0.2.3 of remote-pagination plugin, which includes an option to enable user to change page sizes out of the given options. As given in the documentation, lets have a look at the example below : //Example Domain: class Book { String title String author } //Example controller: class BookController { […]
In one of the projects, we had used Query Caching to improve the performance. However, it also meant that the updates/inserts into a table did not get reflected immediately, i.e. something like: DomainClass.findByPropertyName(“propertyName”, [cache: true]) returned the same list as it was, before the insertion/updation took place. We found that this could be resolved by […]
Recently, we had a requirement where secure URLs were to be made accessible to Google. Our implementation was to send a url with token valid for 10 seconds. The token expired automatically after 10 seconds. We used time based cache for this as described here: T set max time to 10 seconds , I set […]
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 […]