Grails in Action, Second Edition
Glen Smith and Peter Ledbrook
Foreword by Dierk König
  • June 2014
  • ISBN 9781617290961
  • 576 pages
  • printed in black & white

Provides a solid foundation ... covers best practices and background knowledge.

From the Foreword by Dierk König, author of "Groovy in Action"

Grails in Action, Second Edition is a comprehensive introduction to Grails 2 focused on making you super-productive fast. In this totally revised new edition, you'll master Grails 2.3 core skills as you apply TDD techniques to developing a full-scale Twitter clone. Along the way you'll learn the latest single-page web app UI techniques, work with NoSQL backends, integrate with enterprise messaging, and implement a complete RESTful API for your services.

Table of Contents show full


preface acknowledgments about this book about the title about the cover illustration





Part 1 Introducing Grails

1. Chapter 1 Grails in a hurry . . .

1.1. Introducing Grails

1.2. Getting set up

1.3. QOTD: your sample program

1.4. Creating the domain model

1.5. Adding UI actions

1.6. Improving the architecture

1.7. Summary and best practices

2. Chapter 2 The Groovy essentials

2.1. Writing your first script

2.2. Creating a quote analyzer class

2.3. Going to the next level

2.4. Summary and best practices

Part 2 Core Grails

3. Chapter 3 Modeling the domain

3.1. Introducing the Hubbub sample application

3.2. Your first domain class object

3.3. Validation: stopping garbage in and out

3.4. Defining the data model—1:1, 1:m, m:n

3.5. Summary and best practices

4. Chapter 4 Creating the initial UI

4.1. Creating instant UIs with scaffolding

4.2. Restyling the scaffolding

4.3. Working with the scaffolding code directly

4.4. Summary and best practices

5. Chapter 5 Retrieving the data you need

5.1. Setting up the data and search form

5.2. Writing Where queries

5.3. When Where queries aren’t suitable

5.4. Summary and best practices

6. Chapter 6 Controlling application flow

6.1. Controller essentials

6.2. Implementing a timeline for Hubbub

6.3. Testing controller actions: an introduction to mocking

6.4. From controller to view

6.5. Exploring scopes

6.6. Handling default actions

6.7. Summary and best practices

7. Chapter 7 Services and data binding

7.1. Services: making apps robust and maintainable

7.2. Data binding

7.3. Command objects

7.4. Working with images

7.5. Intercepting requests with filters

7.6. Creating custom URL mappings

7.7. Summary and best practices

8. Chapter 8 Developing tasty forms, views, and layouts

8.1. Understanding the core form tags

8.2. Extending views with your own tags

8.3. Adding delicious layouts

8.4. Applying Ajax tags

8.5. Summary and best practices

Part 3 Everyday Grails

9. Chapter 9 Building reliable applications

9.1. Running tests

9.2. Understanding Grails unit tests and mocks

9.3. Testing the application as a whole

9.4. Summary and best practices

10. Chapter 10 Using plugins: just add water

10.1. Taking advantage of others' hard work

10.2. Adding mail support

10.3. Caching for performance: making everything snappy

10.4. Database migrations: evolving a schema

10.6. Summary and best practices

11. Chapter 11 Protecting your application

11.1. Dealing with untrusted data and networks

11.2. Access control

11.3. Further exploration of Spring Security

11.4. Summary and best practices

12. Chapter 12 Exposing your app to other programs

12.1. Creating a REST interface

12.2. Improving the API

12.3. Securing and maintaining the API

12.4. Summary and best practices

13. Chapter 13 Single-page web applications (and other UI stuff)

13.1. Revisiting Grails web resource management

13.2. RESTful clients with AngularJS

13.3. Advanced RESTful CRUD: implementing in-place editing

13.4. Summary and best practices

14. Chapter 14 Understanding Spring and transactions

14.1. Spring fundamentals

14.2. Using transactions with GORM

14.3. Summary and best practices

Part 4 Advanced Grails

15. Chapter 15 Understanding events, messaging, and scheduling

15.1. Lightweight messaging with Platform Core

15.2. A hitchhiker’s guide to JMS messaging

15.3. Using the Grails JMS plugin

15.4. Scheduling tasks with Grails

15.5. Advanced scheduling

15.6. Summary and best practices

16. Chapter 16 NoSQL and Grails

16.1. The problem with PostgreSQL (or when to choose NoSQL)

16.2. Types of NoSQL databases (and typical use cases table)

16.3. Using Redis to work with key-value stores

16.4. Using MongoDB to work with document-oriented data

16.5. Using Neo4j to work with graph-oriented data

16.6. Summary and best practices

17. Chapter 17 Beyond compile, test, run

17.1. Getting to deployment

17.2. Integrating Grails with Maven

17.3. Grails with Gradle

17.4. Summary and best practices

18. Chapter 18 Grails in the cloud

18.1. Getting to know the cloud

18.2. Running in the cloud

18.3. Summary and best practices

Appendix A: Groovy reference

GORM query reference
XML and Spring builders


© 2014 Manning Publications Co.

About the Technology

It may be time for you to stop reconfiguring, rewriting, and recompiling your Java web apps. Grails, a Groovy-powered web framework, hides all that busy work so you can concentrate on what your applications do, not how they're built. In addition to its famously intuitive dev environment and seamless integration with Spring and Hibernate, the new Grails 2.3 adds improved REST support, better protection against attacks from the web, and better dependency resolution.

About the book

Grails in Action, Second Edition is a comprehensive introduction to Grails 2. In this totally revised edition you'll master Grails as you apply TDD techniques to a full-scale example (a Twitter clone). Along the way you'll learn single-page web app techniques, work with NoSQL back ends, integrate with enterprise messaging, implement a RESTful API ... and more.

No Java or Groovy knowledge is required. Some web development and OOP experience is helpful.

What's inside

  • Covers Grails 2.3 from the ground up
  • Agile delivery and testing using Spock
  • How to use and manage plugins
  • Tips and tricks from the trenches

About the reader

No Java or Groovy knowledge is required. Some web development and OOP experience is helpful.

About the authors

There's no substitute for experience: Glen Smith and Peter Ledbrook have been fixtures in the Grails community, contributing code, blogging, and speaking at conferences worldwide, since Grails 0.2.

combo $49.99 pBook + eBook
eBook $39.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks

The canonical guide to Grails.

Jerry Gaines, 4impact Group

Packed with practical examples.

Pratap Chatterjee, Karolinska Institute

The best resource to help you get ridiculously productive!

Michael A. Angelo, Laird Technologies