small medium large xlarge

Grails 2: A Quick-Start Guide


Cover image for Grails 2: A Quick-Start Guide

Grails 2: A Quick-Start Guide


Java web development is notoriously tedious, but help is on the way. Grails takes the pain out of web development and brings back the fun. This beginner’s guide gets you up and running with Grails as you construct an original, working application from start to finish. In this new edition, you’ll be building an application entirely with Grails 2, which allows you to take advantage of the new HTML 5 scaffolding, dramatic performance improvements, and enhancements new to Groovy 2.

Customer Reviews

This book is a delight: a warm, smart introduction to the Grails framework, illustrated by a friendly mentor over several iterations on a small project. It’s pair-programming on the page. By the end of the ride, we’ve created an impressive app, and we’re ready for deeper dives, with a wealth of resources provided. Fabulous!

- Michael Easter

Software composer,

If you are looking for a book to take you from Java to productivity with Grails as quickly as possible, this is your book. Dave has produced a fantastic and pragmatic iterative guide to building a full Grails application, including advice for development and production. This book is the quickest way to accelerate your learning of Grails.

- Ken Sipe

, Code Mentor, Inc.

Dave and Ben have done it again. Grails 2: A Quick Start Guide is the best book you could hand to a new Grails developer. It’s a great mix of instruction and practice and just what you need to get started, or get better, with Grails.

- Jared Richardson

Agile coach, Agile Artisans

See All Reviews

What You Need

Grails 2 will run on any machine that supports Java. Grails applications can be deployed on any Java Servlet container, including Tomcat, Jetty, WebLogic, JBoss, and Websphere.

User Level

This book is for web developers who have done some Java web development.

Contents & Extracts

Greetings and Salutations!
  • Let Me Tell You About Grails…
  • How Does Grails Do It?
  • Why This Book?
  • Who Should Read This Book
  • Source Code
  • Acknowledgments
  • Enough Groovy to Be Dangerous
    • Groovy Syntax Compared to Java
    • Groovy Strings
    • Groovy Closures
    • Groovy Collections
    • Metaprogramming
    • Where to from Here?
  • Our Project
    • Introducing
    • Meet Our Customer
    • Iteration Zero
    • Summary
  • Laying the Foundation
    • Creating a Domain Class
    • More About Domain Classes
    • Testing Our Domain Class
    • Taking Control of Our Domain
    • Modifying Code That Doesn’t Exist
    • Bootstrapping Some Test Data
    • Summary
  • Building Relationships
    • The TekUser Domain Class
    • One-to-One Relationships
    • One-to-Many Relationships
    • Collections of Simple Data Types
    • Adding a Sponsor Class
    • Many-to-Many Relationships
    • Finishing Up the Domain Model
    • Summary
  • Beyond Scaffolding
    • Generating Scaffolding Code
    • Anatomy of a Grails Controller
    • Grails Views with Groovy Server Pages
    • Configuring a Database
    • Summary
  • Getting Things Done excerpt
    • Changing All Our Views at Once
    • Modifying the Scaffolded Views
    • Event Task List
    • Grails Service Classes
    • Integration Testing
    • Modifying the Task Class
    • Summary
  • Forum Messages and UI Tricks
    • Restricting Messages to an Event
    • Of Templates and Ajax
    • Display Message Threads with a Custom Tag
    • Summary
  • Knock, Knock: Who’s There? Grails Security excerpt
    • Grails Security Options
    • Logging In
    • Filters
    • Logging Out
    • Summary
  • Big-Picture Views
    • Home Page Makeover
    • Creating a New Controller
    • Designing the Dashboard View
    • Adding the Dashboard Action
    • Adding a Menu
    • Linking to the Dashboard
    • Summary
  • Seek, and You Shall Find
    • Search Using Dynamic Finders
    • Hibernate Criteria Builder
    • The Big Guns: The Searchable Plugin
    • Summary
  • Icing on the Cake
    • The jQuery UI Plugin
    • The Twitter4J Plugin
    • User-Friendly URLs
    • Summary
  • Deployment and Beyond
    • Using a JNDI Data Source
    • Creating and Deploying a WAR
    • Next Steps
    • Parting Thoughts
  • Additional CSS Rules
  • Resources
    • Online Resources
    • Meet the GR8 Community
    • Other Resources
    • IDE Support


Dave Klein is a consultant helping organizations of all sizes to develop applications more quickly with Grails—and have more fun doing it. Dave has worked as a developer, architect, project manager, mentor, and trainer for the past 18 years, and has presented at user groups and national conferences. Dave’s Groovy and Grails-related thoughts can be found at

Ben Klein began his Grails career in 2008 and is now a developer at Silver Chalice, where he works on Grails projects for clients large and small. He collects Groovy-related books, has written for GroovyMag, and is the author of Rizzo, the Groovy static site generator.