2. Peter Maas ~ Works at Finalist IT
Group. 70% Developer, 25% Architect
and 5% CTO Board. Experience
includes Java/JEE, Spring, Hibernate,
i B a t i s , J S F, S t r u t s , M M B a s e.
Passionate about scripting languages
for the JVM like Groovy and JRuby.
3. So, what is Grails?
In its' essence Grails is an MVC action-based webframework
· CoC: convention over configuration
· DRY: don't repeat yourself
· TDD: test driven development
· Combines advantages of frameworks like
RoR/Django/Turbogears with proven Java technology
6. Key Advantages
· Lowers the steep learningcurve of the Java platform
· Brings (back) both productivity and pleasure of development
· Lets you build applications in an incremental/iterative way
· Allows you to scale your application in complexity and infrastructure
7. DEMO
Battle
Registration Presentation
1 name 1
* * name
name
description
email description
date
8. Domain classes
class Registration {
class Battle { class Presentation {
String name
String name String name
String email
String description String description
Criteria
Battle battle
Date date Battle battle
static belongsTo = [Battle]
static hasMany = static belongsTo = [Battle]
def listByRegistration = {
[presentations:Presentation,registrations:Registration]
def c = Battle.createCriteria()
static constraints = {
def results = c{
static constraints = { static constraints = {
name(blank: false)
registrations{
name(blank: false) name(blank: false)
email(blank: false,
like(quot;namequot;,quot;%${params.name}%quot;)
description(blank: false) description(blank: false)
email: true)
}
date(nullable: false) battle(nullable: false)
battle(nullable: false)
order(quot;datequot;,quot;descquot;)
} }
}
}
def String toString(){ def String toString() {
def String toString() {
render(view:'list',model:[battleList: results])
return name return name
return name
}
} }
}
} }
}
g:textArea
Bootstrap
Battle b =
new Battle(name: quot;Battle of the Geeks 2007quot;, description: quot;Finalists BOTG 2007quot;, date: new Date()) <g:textArea name=quot;myFieldquot; value=quot;myValuequot; rows=quot;5quot; cols=quot;40quot;/>
b.save()
[quot;CMScquot;, quot;Guicequot;,quot;Grailsquot;,quot;Mulequot;].each{
Spring config
Presentation p =
new Presentation(name: quot;${it} presentationquot;, description: quot;presentation about ${it}quot;, battle: b)
p.save()
}
<bean id=quot;textileParserquot; class=quot;com.plink.plextile.TextParserquot;/>
Taglib Render AS
import com.plink.plextile.*;
import grails.converters.*
class TextileTagLib {
...
TextParser textileParser
def showXML = {
def renderTextile = { attrs ->
Battle b = Battle.get( params.id)
out << textileParser.parseTextile(attrs.value, true)
render b as XML
}
}
}