![Page 1: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/1.jpg)
Rapid Web Development for the Java Platform
Published under the Creative Commons Attribution Noncommercial Share Alike License Version 2.5. (Please see http://creativecommons.org/licenses/by-nc-sa/2.5 for complete details.)
Getting Started with Grails
Jason [email protected]
![Page 2: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/2.jpg)
Introduction
Jason Rudolph
Grails Committer
Streamlined Committer
Principal @ Relevance
Author
![Page 3: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/3.jpg)
What is Grails?
Rapid web application development
Getting things done
Having fun doing it
Full-stack MVC framework
Open source
Runs on the JVM
![Page 4: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/4.jpg)
What (Else) is Grails?
Develop your apps in Groovy
Highly-expressive
Fully object-oriented
Dynamic
Familiar syntax
Seamless Java integration
JSR-241
![Page 5: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/5.jpg)
Anything Else?
Convention over configuration
Opinionated software
Sensible defaults
Everything has a place
DRY (Don't Repeat Yourself)
![Page 6: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/6.jpg)
Rock-Solid Foundation
![Page 7: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/7.jpg)
Let’s Get StartedReady?
Install JDK 1.4 (or higher)
Set JAVA_HOME
Set
Download latest Grails release
Set GRAILS_HOME
Add $GRAILS_HOME/bin to your PATH
Grails!
![Page 8: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/8.jpg)
Hello, GrailsDemo
![Page 9: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/9.jpg)
What’sInside?
![Page 10: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/10.jpg)
Instant GratificationDemo
![Page 11: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/11.jpg)
Grails ORM (GORM)
Zero-configuration persistence management
DAOs Dynamic domain class methods
save
delete
get
list
find
findAll
count
etc.
![Page 12: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/12.jpg)
Relationship Counseling
![Page 13: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/13.jpg)
1:n Relationships
class Race { //... static hasMany = [registrations:Registration]}
class Registration { //... Race race
static belongsTo = Race}
![Page 14: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/14.jpg)
Relationship Counseling
Demo
![Page 15: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/15.jpg)
Where’s My Data
How did we get this far without a database?
Hooking up an external database
Create schema
Grant permissions
Add drivers to racetrack/lib
Update data source
![Page 16: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/16.jpg)
Be PersistentDemo
![Page 17: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/17.jpg)
Declaring Constraints
Pre-packaged constraints
Custom constraints
blank
creditcard
inList
min
max
matches
nullable
range
unique
url
etc.
![Page 18: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/18.jpg)
Show Some Constraint!
Demo
![Page 19: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/19.jpg)
Fun with URLshttp://localhost:8080/racetrack/race/show/2
![Page 20: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/20.jpg)
Fun with URLshttp://localhost:8080/racetrack/race/show/2
class RaceController { //... def show = { [ race : Race.get( params.id ) ] } //...}
![Page 21: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/21.jpg)
GSP
![Page 22: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/22.jpg)
RaceController.groovy
def show = { [ race : Race.get( params.id ) ] }
views/race/show.gsp
<g:each var="r" in="${race.registrations}"> <li> <g:link controller="registration" action="show" id="${r.id}">${r.name} </g:link> </li> </g:each>
![Page 23: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/23.jpg)
Groogle?
![Page 24: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/24.jpg)
Get Dynamic
What if I need to...
find all races in Virginia?
count the races longer than 5 miles?
get a list of the 10 longest races?
find races matching a certain pattern?
list all races with registrations?
Dynamic Finder Methods
![Page 25: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/25.jpg)
Get DynamicDemo
![Page 26: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/26.jpg)
Putting It to the Test
Unit & integration testing
GroovyTestCase created for each class
grails test-app executes all test cases
Functional testing
Canoo Web Test
grails generate-webtest
grails run-webtest
![Page 27: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/27.jpg)
Deploymentgrails war
![Page 28: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/28.jpg)
Beyond the Finish Line
Services
Web Flow
REST
Java Integration (src/java)
Rich (and Friendly) Tag Libraries
Ajax
![Page 29: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/29.jpg)
Still More to Explore
Custom URL Mapping
Alternate Domain Implementations
Mapping to legacy schemas
EJB3 entity beans
Job Scheduling
Command Objects for Forms
![Page 30: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/30.jpg)
grails.org/plugins
Build rich clients
Expose web services
Secure your app
Roll your own scaffolding
Integrate a search engine
Almost limitless possibilities
![Page 31: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/31.jpg)
grails.org/roadmap
Future Releases
Object-Relational Mapping DSL
Support for JSP custom tag libraries in GSP
JavaScript DSL
Domain model generation from database schema
JPA support
![Page 32: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/32.jpg)
Important Companies Talking About Grails
Oraclehttp://www.oracle.com/technology/pub/articles/grall-grails.html
BEAhttp://dev2dev.bea.com/pub/a/2006/10/introduction-groovy-grails.html
SAPhttps://www.sdn.sap.com/irj/sdn/wiki?path=/display/Community/Composition+on+Rails
![Page 33: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/33.jpg)
Resources
grails.org
Downloads
Latest release (0.6)
Development snapshot (1.0-RC1)
User guide, tutorials, screencasts, etc.
Mailing lists (grails.org/mailing+lists)
![Page 34: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/34.jpg)
aboutGroovy.com
grails.org/grails+podcast
groovyblogs.org
Resources (cont’d)
![Page 35: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/35.jpg)
2007 No Fluff Just Stuff
Northern Virginia Software Symposium
November 02 - 04, 2007
Sheraton Reston
nofluffjuststuff.com/conference/reston/2007/11
![Page 36: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/36.jpg)
Books
![Page 37: Getting Started Rapid Web Development for with Grails the Java …€¦ · What is Grails? Rapid web application development Getting things done Having fun doing it Full-stack MVC](https://reader033.vdocument.in/reader033/viewer/2022052001/60142a1131142b4bef6b8f23/html5/thumbnails/37.jpg)
This presentation is published under the Creative Commons Attribution Noncommercial Share Alike License Version 2.5.
(Please see http://creativecommons.org/licenses/by-nc-sa/2.5 for complete details.)