svcc intro to grails
TRANSCRIPT
Introduction to Grails
James Williams
Introduction
James Williams
Groovy committer
Author of Google charts plugin
Griffon co-creator
Creator of SwingXBuilder
Agenda
What is Grails?
Domain Classes
Controllers
GSP/Taglibs
Plugins
Web Services
Conclusion
What is Grails?
Rapid web application development
Full-stack MVC framework
Open source
Runs on the JVM
What is Grails? (cont'd)
Integrates best of breed tools...
And many more...
Grails Quickstart
Install Grails
Run grails create-app
Run grails run-app
Domain Classes
Core objects that make up a Grails app
Are seamlessly persisted to storage
Can have constraints on values
Can have relationships with other domain classes
Constraints
Determine the validity of member fields
blank
creditCard
inList
matches
max
maxSize
min
minSize
notEqual
nullable
range
scale
size
unique
url
validator
Grails ORM (GORM)
No hassle database persistence
Leverages Hibernate but minus .hbm files and other messy configuration files
Provides dynamic domain class methods like...
create
save
delete
update
get
find
findAll
addTo
count
....
Relationships
One to one
One to many (hasMany)
Many to many
Demo
Domain Classes Demo
Controllers
Manages requests and response for domain objects
Unless overridden, maps requests to a REST-like structure
//action_name
It's actions can be generated on the fly by the application
Groovy Server Pages
Provide views for domain objects
Like JSP, GSPs can be a mix of markup, Groovy code and GSP tags*
Generally correspond to an associated action in the controller
Code fragments use the and forms, though this is discouraged
Typical GSP
%>
Taglibs
Allow the developer to simplify blocks of code
Similar to JSP tag libs
class SimpleTagLib {
def emoticon = { attrs, body
out