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
Grails ,
Groovy


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

Industrial Strength Groovy

Paul King presents some of the tools helping one programming in Groovy: Cobertura, CodeNarc, EasyB, GroovyDoc, GroovyMock/Spock, Hudson, Maven/Ant/Gant/Gradle, OSGi, and Spring/Guice.

Authorizing process access and execution with JBoss jBPM

In this article Boris Lublinsky shows how to extend JBoss jBPM to define and support process access authorization.

Nathaniel Talbott on Experiment Driven Design

Nathaniel Talbott discusses the concept of Experiment Driven Design.

Jesse Fewell on Growing PMI using Agile

The session is an experience report that tells the PMI Agile Forum story in roughly chronological order.

QCon SF Keynote: Techie VC's Talk About Trends & Opportunities

Kevin Efrusy and Salil Deshpande talk about what makes a business successful or not, presenting three actual cases they have been involved with: Hyperic, G2One, SpringSource.

Project Lead Mark Fisher Discusses the Spring Integration Project

InfoQ talks to Mark Fisher, project lead for the Spring Integration project, about the framework.

How HTML5 Web Sockets Interact With Proxy Servers

Peter Lubbers explains in this article how HTML5 Web Sockets interact with proxy servers, and what proxy configuration or updates are needed for the Web Sockets traffic to go through.

Rails in the Large: How Agility Allows Us to Build One Of the World's Biggest Rails Apps

Neal Ford shows what ThoughtWorks learned from scaling Rails development: infrastructure, testing, messaging, optimization, performance.