I had two applications that communicate with each other through web-services. There I had a requirement to send multi-part file from one application to another. After searching I came out with the following solution and thought to share: [java] import org.apache.http.entity.mime.MultipartEntity import...
A few days ago I faced a problem of evaluating dynamic expressions on domain objects. The scenario was that, depending upon the user input, I needed to sort a list of objects on some properties, which were nested deep in the object, e.g., [java] student.course?.college?.name // if a user chose to sort students by college name ...
Suppose a scenario, where User and Account classes are linked as below: [groovy] class Account { String email String password // ... other fields } class User { Account account String name String address // ... other fields } [/groovy] At the time of creating a new User, and accessing the user...
Hi, In one of my Grails project, i needed to 'Like' any Facebook wall post using facebook API. I searched about it and found a way to achieve this using Facebook Graph API and thought it worth sharing. To achieve it, we should have a valid facebook access_token, which can be obtained using steps described here. After obtaining a...
Hi, In my recent grails project, i needed to post images to the albums for Facebook Profile/ Fan page/ Group using facebook API. I searched a lot and find a way to achieve this using Facebook Graph API. To post any content over facebook, we need to have facebook access_token which can be obtained using steps described here After...
Perhaps, you know it before or just skipped it after going through Java API. But I really found it very helpful at this point. Recently, I had a requirement in an open-source project, where users can iterate through the objects saved in collections (esp. List). But the problem was, we really didn’t want users to directly or...
Hi, Recently, in my project while downloading some files(not on all files) i am getting exception on chrome, that say : Duplicate headers received from server Error 349 (net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION): Multiple Content-Disposition headers received. This is disallowed to protect against HTTP...
Groovy 2.0 comes with some amazing new features, which prompted a numbering scheme jump from 1.9.x to 2.0. One of the key features that I took note while going through Guillaume Laforge's presentation at 33rd Degree was the support for plain language sentences made possible by optional parentheses, and dots. We love the language...
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...
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...
Recently, I saw some code of grails Hibernate Plugin and noticed an interesting usage of 'as' operator. The 'as' operator of groovy is typically used to change the types of objects. For example: [groovy] int a = "20" as int assert a==20 [/groovy] The 'as' operator can be used to provide implementation to interface as...
Hi guys, Recently on a project, I was creating a number of command objects to accept incoming parameters from a POST call from an iPhone with which I needed to sync data. I created a parent class for all command object classes to accept the common properties and created individual command object classes to accept any additional...