InfoQ

Minibook

Getting Started with Grails, Second Edition

Posted by Scott Davis & Jason Rudolph on Feb 06, 2010

Community
Java
Topics
Dynamic Languages ,
Web Frameworks
Tags
Groovy ,
Grails


Grails is a Java- and Groovy-based web framework that is built for speed. First-time developers are amazed at how quickly you can get a page-centric MVC web site up and running thanks to the scaffolding and convention over configuration that Grails provides. Advanced web developers are often pleasantly surprised at how easy it is to leverage their existing Spring and Hibernate experience.

"Getting Started with Grails" brings you up to speed on this modern web framework. Companies as varied as LinkedIn, Wired, Tropicana, and Taco Bell are all using Grails. Are you ready to get started as well?

160 pages, 6" x 9", ISBN: 978-0-557-18321-0

Free download

Courtesy of Scott Davis, Jason Rudolph and and InfoQ.com, we're happy to offer a free version for download, to get this knowledge in as many peoples hands as possible. Login to download this book FREE (PDF)

Buy the print version for $22.95

If you enjoyed reading the free download version, please support the author and InfoQ's book series by buying the print version for only $22.95.

Table of Contents

1. INTRODUCTION
Learning by Example
The RaceTrack Application

2. INSTALLING GRAILS
Installing a JDK
Installing Grails
Installing a Database

3. CREATING A GRAILS APPLICATION
Creating the RaceTrack Application
The Grails Directory Structure
Domain Classes
Scaffolding Controllers and Views

4. VALIDATION
Customizing the Field Order
Adding Validation
Changing Error Messages
Creating Custom Validations
Testing Validations

5. RELATIONSHIPS
Creating a One-to-Many Relationship
Creating a Many-to-Many Relationship
Bootstrapping Data

6. DATABASES
GORM
DataSource.groovy
Switching to an External Database

7. CONTROLLERS
create-controller vs. generate-controller
Understanding URLs and Controllers
From Request to Controller to View
A Quick Look at GSPs
Exploring the Rest of the Controller Actions
Rendering Views That Don’t Match Action Names

8. GROOVY SERVER PAGES
Understanding GSPs
Understanding SiteMesh
Understanding Partial Templates
Understanding Custom TagLibs
Customizing the Default Templates

9. AUTHENTICATION
Implementing User Authentication
Unit Testing Controllers
Creating a Password Codec
Creating an Authorization TagLib
Leveraging the beforeInterceptor
Leveraging Filters
Security Plugins

10. PLUGINS AND SERVICES
Understanding Plugins
Installing the Searchable Plugin
Exploring the Searchable Plugin
Understanding Services
Adding a Search Box
Changing the Home Page with UrlMappings
Production Deployment Checklist
Conclusion

Author Bios

Scott Davis is the founder of ThirstyHead.com, a training company that specializes in Groovy and Grails training. Scott published one of the first public websites implemented in Grails in 2006 and has been actively working with the technology ever since. Author of the book Groovy Recipes: Greasing the Wheels of Java and two ongoing IBM developerWorks article series (Mastering Grails and in 2009, Practically Groovy), Scott writes extensively about how Groovy and Grails are the future of Java development. Scott teaches public and private classes on Groovy and Grails for start-ups and Fortune 100 companies. He is the co-founder of the Groovy/Grails Experience conference and is a regular presenter on the international technical conference circuit (including QCon, No Fluff Just Stuff, JavaOne, OSCON, and TheServerSide). In 2008, Scott was voted the top Rock Star at JavaOne for his talk "Groovy, the Red Pill: How to blow the mind of a buttoned-down Java developer".

Jason Rudolph is a Partner at Relevance, a leading consultancy and training organization specializing in Ruby, Rails, Groovy, and Grails and integrating them into enterprise environments. Jason has more than a decade of experience in developing software solutions for domestic and international clients of all sizes, including start-ups, Dow 30 companies, and government organizations. Jason speaks frequently at software conferences and user groups, and also he's been known to write about software development from time to time. Jason was an early committer to Grails and contributes regularly to the open source community. More recently, Jason can be found working on Tarantula, Blue Ridge, and other Ruby and Rails projects dedicated to testing and improving code quality. Jason holds a degree in Computer Science from the University of Virginia. He currently lives in Raleigh, NC with his wife (who can take a functional web app and make it actually look good) and his dog (who is hard at work on her upcoming book, Getting Started with Squirrels).

Educational Content

Brian Marick on 4 Challenges and 5 Guiding Values of Agile Software Development

Brian Marick takes us through a quick tour of the most important values and challenges to adopting Agile successfully (they aren't the typical challenges and values we hear in the community).

Are You a Software Architect?

The line between development and architecture is tricky. Does it exist at all? Is an ivory tower actually needed? There's a balance in the middle, but how do you move from developer to architect?

Agile – A Way of Life and Pragmatic Use of Authority

The word 'authority' sometimes produces an allergic response in hard-line agilists. Freedom and authority – both are bad if misused and both are good if used in right spirit for a noble cause.

Getting Started with Grails, Second Edition

"Getting Started with Grails" brings you up to speed on this modern web framework. Companies as varied as LinkedIn, Wired, and Taco Bell are all using Grails. Are you ready to get started as well?

Using ITIL V3 as a Foundation for SOA Governance

Those familiar with only ITIL V2 often scoff at the thought that ITIL could serve as a governance framework for SOA. With ITIL V3, the focus of the framework shifted towards service-orientation.

Adrian Colyer on AspectJ, tc Server and dm Server

SpringSource CTO Adrian Colyer discusses AspectJ, SpringSource's dm Server and tc Server products, OSGi and Scrum.

Adam Wiggins on Heroku

Heroku's Adam Wiggins talks about Rails, Background Jobs, Add-Ons, Ruby, and how Heroku manages to work around Ruby's inefficiencies using Erlang and other languages.

SOA as an Architectural Pattern: Best Practices in Software Architecture

For Grady Booch the foundation of a good architecture is patterns, SOA being just one of many patterns. In this Second Life presentation, Booch attempts to bring more clarity on what architecture is.