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 […]
Of-late my laptop has been highly responsive …. as responsive as a sloth can be… 😛 I mean you wouldn’t be expecting an Intel i5 Processor with 4GB Ram and 500GB hard disk making you go for a coffee break every time you had to build or compile your code. I am sure many of […]
Load Testing is one of the major aspect which we all do for our applications, especially for those which have publicly available pages and has very heavy traffic. JMeter is a very commonly used tool for doing load testing. As developers, it is a very good tool to have in our skill set. However […]
Of late, I have been thinking about the popularity of grails interactive mode amongst developers. I found that though most of us are aware of this mode but we don’t use it as often, as it should be. Where should I use grails –interactive mode while developing in grails? The answer may vary from person […]
Here is an example of how to design Grails domain class with Intellij Idea.For this we need to have blank domain classes. So lets say we created three Domain Classes Company,Book,Author To see relationship diagram, Selected Domain Class, and selected tab Domain Class Dependencies.It should look like this Lets assume the relation that publication has many […]
Grails does not support accessing multiple file input fields with same name using params.fieldName. We need to use request.multiFileMap (available in Spring 3.0) instead of request.fileMap. The blog provides sample code to achieve this feature via Grails Filter.
We had a requirement in a recent project to expose some of the functionality we had via a JSON API. The functionality needed to be secure, as was the initial web interface which exposed the functionality. We were using Spring Security for the security aspect of our application. The spring security plugin, together with a […]
Using commons-validator jar for validation emails, date, url, credit card etc. This jar file is bundled with the grails jar files. So writing regular expressions or creating command objects/domains for the single field validation is overkilling. The jar file has a special class GenericValidator for validating well-known data types.
If you are using Grails Spring Security in your application, one killer functionality that we can easily provide is a simple user switcher Add this to your admin layout: [html] <sec:ifAllGranted roles=’ROLE_ADMIN’> <form action=’/j_spring_security_switch_user’ method=’POST’> Switch: <g:select from="${users}" optionKey="username" optionValue="displayInfo" name=’j_username’/>&nbsp;<input type=’submit’ value=’Switch’/> </form> </sec:ifAllGranted> <sec:ifSwitched> <a href=’${request.contextPath}/j_spring_security_exit_user’> Resume as <sec:switchedUserOriginalUsername/> </a> </sec:ifSwitched> [/html] In […]
If you have an S3 bucket with a huge number of files, and you want to delete the bucket, you need to empty the bucket first. If the bucket has a handful of files, then it is easy enough from the AWS interface, but if the bucket has a large number of files, then AWS […]
Groovier way of finding index of element from Map. It can be obtained with findIndexOf Method, which accepts closure as argument. [groovy] Map map=["groovy":1,"grails":2,"index":3,"element":4] assert 3 == map.findIndexOf{it.key=="element"} assert 0 == map.findIndexOf{it.value==1} [/groovy]
When response time of a page is slow, we might be interested in viewing database queries executed on that page. Enabling SQL Logging shows all queries but we are interested in queries for that particular request only. We can get this information by just simply adding the following filter to our application(Filters in Grails) [groovy] […]