Miguel PingIntroduction to Grails Framework18/03/2010
Small Introduction on Groovy
Grails
Grails = Groovy on (G)Rails
Grails is MVC
Powered by Spring and Hibernate
Model/Domain Layer
View Layer
Controllers
DemoAgenda
Groovy+=
Java ClasspublicclassHelloWorld {privateString name;publicvoidsetName(String name) {this.name = name;  }publicStringgetName() {return name;  }publicStringgreet() {return"Hello "+ name;  }publicstaticvoidmain(String[] args) {HelloWorldhelloWorld=newHelloWorld();helloWorld.setName("Groovy");System.out.println(helloWorld.greet());  }}
Groovy ClasspublicclassHelloWorld {privateString name;publicvoidsetName(String name) {this.name = name;  }publicStringgetName() {return name;  }publicStringgreet() {return"Hello "+ name;  }publicstaticvoidmain(String[] args) {HelloWorldhelloWorld=newHelloWorld();helloWorld.setName("Groovy");System.out.println(helloWorld.greet());  }}
Multiple classes per file, or even no classes at all (scripts)
Public unless defined otherwise
Getters and Setters by default
String interpolation
Semicolons are optional
Type declarations are optional
Return keyword is optionalGroovy Featuresclass HelloWorld {def namedefgreet() { "Hello ${name}" }}helloWorld =newHelloWorld(name: "Groovy")println helloWorld.greet()
Dynamic language (everything happens at runtime)
Dynamically typed (types are “optional”)
Closures
Anonymous Inner Classes (recently)
Meta Object Protocol
Hence, MetaClasses and all the magic
Compiles down to bytecode

Introduction to Grails Framework

Editor's Notes

  • #5 Similarities to Jboss SeamWe can see by this slide the commands syntax
  • #6 Some constraints are mapped to DB constraints, although when removing a constraint grails do not remove the correspondent db constraint.
  • #7 Intro to taglib, grails style. Mapping to closure. Almost no need for code in gsp.
  • #8 Explain that Grails is Action-First
  • #9 Talk about maturity
  • #10 Faltou falar de: Ambientes, Testes, Scripts, GORM criteria, DSL para beans spring, Plugin Migrações
  • #11 Configuration Files