Hi, In my current grails project, we are using Facebooks Apps for our application so that any user who wish to use that app, can attach it with his/her Facebook Fan Page manually by visiting the App Profile Page and then adding it to the Fan Page. Then the attached facebook app can fetch data from our project. But few days ago,...
In my current project, i needed to integrate Google+ in the application using server-side API. Google uses OAuth2.0 protocol for authorization when our application tries to access the data. All we require is an access token to fetch data from Google using REST calls which serves data in JSON format. I implemented it using Web Server...
Hi, In one of my recent grails project, i needed to set System property from command line while running the grails application. I looked for it and found a simple solution to do so and found it worth sharing. Suppose we want to set any property, say app.property="propertyValue", then the command to set the property in grails...
Hi, In one of my project i needed to generate EAN-8 standard bar-code for identifying the various products. I searched for various libraries available for generating bar-code and found a library to do so. The library i used for generating the bar-code is Barcode4J. You can download it from here Barcode4J is a flexible generator...
Hi, In my recent grails project, i needed to return back to the application after processing payment at the paypal website. I searched a lot about it. Then i found the solution to do so and thought it worth sharing. Here are the steps i followed:- 1. The Paypal button:- This is the code for putting the paypal button in any...
Hi, In my recent grails project, i came across the situation where i needed to convert the date in given timezone to the date in another timezone. I searched a lot about it and got many solutions for this problem and then i came out with a simple way to do so. Lets i have a date in TimeZone say oldTimeZone and i want to convert it to...
Hi, In my recent grails project, i needed to put focus on the first field of any page whenever the page loads. The requirement is such that if the page contains errors then the focus should be on the first input field which has errors. I searched a lot and with the help of my colleague we came out with a simple JQuery script to put...
Hi, In my recent grails project, i needed to find the existence of particular files on file system. I needed to search in a directory and all of its subdirectories and look into them if the files with the given format exists in it or not. If the files exists, then it should return the complete path of the file. I searched a lot and...
Hi, In my recent grails project, i needed to write unit test cases for testing custom validators which i created in command objects. To test validators, there is a method provided by grails "mockForConstraintsTests()" for validating constraints on Domain as well as Command-Object fields. Let us take a scenario where we needed to use...
Hi, In my recent grails project, i needed to check the occurrence of a word in a string. I could have used contains() method of groovy , but the problem with contains() is that it also matches the word if the word is contained as a substring in any word. I searched a lot, but nothing worked out so i decided to use Regular expression...
Hi all, In my recent grails project, i needed to paginate on an array list, so I wrote a function and thought would share it with you all. public List getFilteredList(int max, int offset) { max = Math.min(max ?: 25, 100) offset = (offset && offset>0) ?: 0 List names = getNames() //Loads the complete list ...
Hi, In one of my projects i needed to create a select-input tag with OPTGROUP options. I searched a lot about it and found that g:select tag do not support OPTGROUP So to solve this problem, i created a simple optgroup tag using Html and grails taglib. I created a Map for the values to be used in the select tag and pass it...