Powered By Blogger

Tuesday, September 27, 2011

Grails

Spring Source tools eclipse is used foe Grails Development.


Now will tell some steps

1. By default in the controller index method will be called
2. In the views folder name of the controller (login) folder will be created if you create loginController

3. In the controller we can instantiate Java classes and call them

4. In the contoller we will have the enclosures.

if you have the enclosure by name search inside LoginController
then it will look for
views --> login-->search.gsp

def search= {
render "abccc.gsp";
}


5. to define variables use def, semicolons are not mandatory

6. USes Gstrings similar to Velocity.


Sample

package com.hersheys.groovy.quickr

import com.hersheys.quickr.migration.TestClass

class LoginController {

/* def index = {

//can be double or string
def i = 4;

System.out.print("Inside the LoginController");

if(i < 0.5){
render "Hellvsgvdso World";
}else{
// brackets are not mandtory
render ("asfasgfasg");
}


//grroovy typeless, no return type , No semicolons , Gstring we have extrac com pared to Java


// Now calling Java

TestClass testClass = new TestClass();
def name = testClass.getNickName("john");

render name;
}
*/

def index = {

//We can configure the gsp to be used as below
//render "abccc.gsp";

// if you leave this method emptry then the index.gsp will be take n from the login folder of views
}


// url --- We can access closure similar to Dispatch Action
//http://localhost:8080/QuickrAlfresco/login/index
//login -- Controller
//index-- closure


def update = {
//render "updatehit"
System.out.print("Inside the update Closure. If we dont return anything then it will look for update.gsp inside song folder in views");
}


def search ={

def x = params.item;
//render x;
request.message = x;
}

}


We can explictly specify the name of the file where to go also

No comments:

Post a Comment