Grails

Using Groovy execute bash scripts

Hi Friends, Recently I had to execute bash script using groovy on a windows server. Though I could easily make the similar script run on linux, but on windows it just didn’t work as it was unable to recognize the internal DOS commands like cp, rm etc. On linux the following code worked but not […]

Amit Jain
Amit Jain
Read

Grails

Using TagLib to avoid changes due to change in URLMappings

Recently, I used Taglib to centralize the effect of URL mapping related changes of my grails application. [java] def userPageLink = {attrs, body -> def user = User.read(attrs.id) out << g.link(controller: ‘user’, action: ‘show’, params: [name: user.name]) {body()} } [/java] So wherever I need a link to user page, I can use this Taglib instead […]

Mohd Farid
Mohd Farid
Read

Grails

File Compression

Creating a zip file using AntBuilder. def ant = new AntBuilder() ant.zip( destfile: destPath, basedir: basePath, includes: includeFiles, // Comma seperated file names excludes: excludeFiles, // Comma seperated file names level: 9 // maximum compression )

Anshul Sharma
Anshul Sharma
Read

Grails

File Uploading using plupload plugin of jquery.

In my grails project i was having the requirement of having multiple file uploading, but in current implementation there was the problem of button being not loaded in Internet Explorer.For that i found plupload very cool to implement this. It has very cool feature of drag and drop and support for almost all browser. Actually […]

Anuj Aneja
Anuj Aneja
Read

Grails

Modifying Grails Scaffolded templates – I

In one of the sessions in SpringOne2GX, there was a session on Uber-Scaffolding by Jean Barmarsh. The session was quite incredible and opened up a world of possibilities. We all know that the scaffolded code generated by grails is modifiable if we install the base templates. This is done simply by saying: [java]grails install-templates[/java] The […]

Himanshu Seth
Himanshu Seth
Read

Grails

Converting date from one timezone to another in groovy

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

Vishal Sahu
Vishal Sahu
Read

Grails

Grails Mail Plugin with DB Driven configuration

We have been coming across a certain use case in a couple of projects that the Email credentials/settings used for sending email should be different based on the from address. This is because the applications act as software services that are used by different organizations, which operate in the same business. And each needed their […]

Vivek Krishna
Vivek Krishna
Read

Grails

How to set default port for grails application

As we all know the default port for grails application is 8080, though we can change the port by running the application by following command [java] grails -Dserver.port=7070 run-app [/java] What if you want the application to run on 7070 by default. Grails provide a very easy way to that as well. You just need […]

Grails

Groovy: Sort list of objects on the basis of more than one field

Usually, when we deal with databases, we don’t face such kind of situation because we query database to get result-set in required order. But let’s say you have a List of objects that you want to sort on the basis of two fields. Let’s discuss it with an example. I have a list of Tasks […]

Salil
Salil
Read
Services