Showing posts with label Grails. Show all posts
Showing posts with label Grails. Show all posts

Friday, May 13, 2016

Grails - How to download zip manually and install using SDKMan

I tried to download the grails using SDKMan with:

 sdk install grails 2.5.4  
but it failed because of slow internet connection.

Then, I went directly to grails.org and downloaded the zip file and added it to /Users/<username>/.sdkman/archives/

To install the plugin, run 

 sdk install grails 2.5.4  

Done!

To see if the plugin is installed,

 sdk list grails  

Wednesday, January 28, 2015

IntelliJ - the intelligent and best IDE for Java Based Projects (such as Grails)

Based on my personal experience, the advantages of using IntelliJ than other IDEs are:

  1. Support for frameworks and languages such as Grails, Groovy (and more)
  2. Support for debugging grails is amazing

Friday, September 26, 2014

Using the asset pipeline grails plugin to write Page Specific Javascript

The Grails Asset-Pipeline is a plugin used for managing and processing static assets in Grails applications. 

Asset-Pipeline functions include processing and minification of both CSS and JavaScript files. It is also capable of being extended to compile custom static assets, such as CoffeeScript or LESS.

Here is one way of using the asset pipeline grails plugin to write Page Specific Javascript

specific.js // will be included by default

      var pageSpecific = function() {  
           console.log('Hello from specific page!)  
      });  
      $(document).ready(function({  
           if($(document.body).data('page') == 'specific') {  
                pageSpecific())  
           }  
      }));  

index.gsp

 <meta name='layout' content='main'/>  
 <body data-page="specific">  
      <h1>Hello from Specific!</h1>  
 </body>  

main.gsp // modify so that it passes the data-page attribute to the JS (since index.gsp uses main as a layout)

 <body data-page"${pageProperty(name:'body.data-page')}">  
      // main body content  
 </body>

Tuesday, July 22, 2014

Grails: CreateCriteria with Projection

Here is an example of using createCriteria() function in grails using projection of sum.

This method returns the sum of Balance in from Finance model/domain.
You can put this code in Bootstrap.groovy to run it when the program starts.

 println Finance.createCriteria().list() {  
                eq('financeType', FinanceTypeEnum.SAVINGS)  
                projections {  
                     sum('balance')  
                }  
           }