Grails

Using AngularJS with Grails app… my first impression

In my current grails application, we have started using the AngularJS after realizing that the GSP template engine is a bit slow. Now, I realize how efficient AngularJS can be, and think of sharing my first impressions while using AngularJS with grails app. Following are some of the reasons, that I find, makes AngularJS stands out: ...

31-Mar-2014

Grails

Grails GSP tag: grep

The other day I was reading the Grails docs and I came across a useful GSP tag: grep. I have been using Grails for over 3 years now but just recently got to see this new tag which has eased my life a bit in situations where the list of objects have to be filtered and iterated at the same time to perform some operations on them. The GSP...

by Abhishek Tejpaul
Tag: gsp
31-Oct-2012

Android, Javascript/Ajax/JQuery

Getting started with jQuery Mobile

JQuery mobile provides set of features which are supported on almost all smartphones such as touch UI, ajax navigation, animated page transitions. Building jQuery mobile page is very simple, here's how: A jQuery Mobile site must start with an HTML5 'doctype' to take full advantage of all of the framework's features. First of all you...

by Puneet Behl
Tag: gsp
15-Sep-2012

Grails

Change user preferred locale using spring’s SessionLocaleResolver

Here we are going to talk about a scenario where there are some records in database which are specific to locale and they need to be displayed as per user's current locale at number of places.Also user can change its preferred locale. For this I preferred to set the user's locale in the session object. There are two ways to do this :- ...

by Nitesh
Tag: gsp
11-May-2012

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...

by Mohd Farid
Tag: gsp
14-Feb-2011

Grails, Javascript/Ajax/JQuery

Grails taglib and JavaScript file

We use internationalization feature in grails using message tag in GSP pages. However arbitrary Groovy/Grails (e.g. tags) code can not be used in JavaScript as they are not executed on server side. To overcome this I used the following way : Declare a JSON object in js file or any where else so that this object is global one. Create a...

by Bhagwat Kumar
Tag: gsp
16-Jan-2011

Grails

Request Mocking to use groovyPagesTemplateEngine in backend threads

We have a setup where a backend thread, fired by the Spring Events, does some processing, generates a PDF and emails the result to the user. The code we were using to generate the HTML from a GSP to be converted to a PDF using iText was as follows : [java] def webRequest = RequestContextHolder.getRequestAttributes() ...

by Vivek Krishna
Tag: gsp
27-Dec-2010

Grails

Grails way for rendering the GSP templates: The tmpl namespace.

Today while working on a project, I paired up with my colleague (Uday)  and we found that we can render a gsp template in a different manner also. Grails provide us a "tmpl" namespace for rendering the GSP templates. The old way that we use to render a gsp template The other way for  rendering the template. Like me,...

by Chandan Luthra
Tag: gsp
01-Oct-2010

Grails, HTML/UI/CSS

Finding User’s Session Locale in GSP

There are situations where you might want to know the Locale of the user as set in the session in your GSP so that you can show text in a particular language/manner. Here the Spring framework's SessionLocaleResolver can come to the rescue. In one of our recent Grails projects, we did the following in one of our GSPs to display the content...

by Abhishek Tejpaul
Tag: gsp
14-Jul-2010

Grails

Injecting Method to trim string length on gsp pages

Restricting the length of a string on gsps is a common scenario in most of our projects. Groovy's metaprogramming magic made it too simple for me. I added the following lines of code to Bootstrap.groovy: Object.metaClass.trimLength = {Integer stringLength -> String trimString = delegate?.toString() String...

by Aman Aggarwal
Tag: gsp
03-May-2010

Grails

How to invoke a GSP tag as a method in Grails GSP

Grails has a lot of gems. One of my favorites (besides GORM) is GSP tags -- Grails makes it so easy to create new tags, now there is no reason to write java/groovy code inside GSPs. One of the features about GSP tags that I discovered and used today is that it is possible to invoke a GSP tag as a method call and assign the output of...

by Deepak
Tag: gsp
16-Sep-2008

Grails

How to pass a bean or model to a template

When we want to render a view using a template and the template makes use of a model object, the model object needs to be passed to the template using GSP tags. I am writing this because it took me a while to figure this out. Thanks to the wonderful contributors on the mailing list who helped me with this. To render the view to a...

by Deepak
Tag: gsp
12-Sep-2008