Applying layout to template at Runtime in Grails Application

There are use cases where we render the template from our action and update some div in the page using ajax. The downside of this approach is when the user hits the url directly in browser address bar and the … Continue reading

Setting count bubble in jQuery mobile Accordian Head

Sometimes we want to show count bubble in Accordion head that is different from the what jQuery mobile provides by default. To add count bubble to Accordian head, we use following piece of code: </pre> <h2>Heading<span class="ui-li-count">10</span></h2> <pre> But it … Continue reading

Redis: Heavyweight Tags – an awesome use-case for caching with Redis

Redis plugin provides a beautiful way to cache the html tags. Using this plugin we can make big savings on the time taken to render the gsp tags.


//Some heavy weight tags rendering
// Lots of db / network operations.

I found this tag extremely helpful in rendering the public facing pages of our site. the pages which refreshed not very frequently and required few seconds to render(if done without caching).

The difference in the time taken to render the page is dependent on our choice of right candidate for Memoizing.

Hope this helps!!!

Best Regards
Mohd Farid

Continue reading

Using PostConstruct annotation with Grails Services

We can use PostConstruct with Grails Services and injected Spring Beans. This PostConstruct annotation can be used to annotate a method which needs to be executed after dependency injection to perform any initialization. import javax.annotation.PostConstruct class PostConstructDemoService { @PostConstruct private … Continue reading

Setting default layout in Grails application

Grails uses Sitemesh for adding layout to the views. Layouts are located in layouts folder and to add layouts to the view we generally add any of the following line in head <g:applyLayout name="layoutName"/> or <meta name="layout" content="layoutName" /> But … Continue reading

Groovy annotations for ToString and EqualsAndHashCode

As I am a lazy programmer most of the time I dont implement toString and equals methods on my grails domain classes. I would like to say thanks to Groovy for helping me out and giving me a ready made … Continue reading