InfoQ

InfoQ

Minibook

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Getting Started with Grails, Second Edition

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

Sections
Development
Topics
Java ,
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

Questions for an Enterprise Architect

Erik Dörnenburg answers: What is Enterprise and Evolutionary Architecture?, discussing 4 issues: Turning strategy into execution, Ensuring conformance, Where do the architects sit? Buying or building?

Wrap Your SQL Head Around Riak MapReduce

Sean Cribbs explains what Map-Reduce and Riak are, why and how to use Map-Reduce with Riak, and how to convert SQL queries into their Map-Reduce equivalents.

Polyglot Persistence for Java Developers - Moving Out of the Relational Comfort Zone

Chris Richardson shows how he ported a relational database to three NoSQL data stores: Redis, Cassandra and MongoDB.

The Golden Circle – Why How What

Jean Tabaka challenges the audience to reflect on what Agile practices they are employing, how they are using them, ending with the questions “Why have their organization chosen to go Agile?

The Web Platform as a Limitless Pool of Innovation, with Andreas Gal

Andreas talks about the benefits of the Open Web and how it compares to proprietary stacks. He also talks about various projects that push the envelope like Boot to Gecko, Broadway and pdf.js.

Hadoop and NoSQLin a Big Data Environment

Ron Bodkin discusses early adoption of Hadoop, NoSQL and describes MapReduce and related libraries and Frameworks. Other topics include Hive, Pig, multi tenancy, and security in a big data environment

Spring and Platform Interoperability

Stephen Bohlen explains how Spring helps with interoperability between Java and .NET, demoing it with the help of a sample application.

How to Stop Writing Next Year's Unsustainable Piece of Code

Guilherme Silveira mentions some of the turning points in project development that may affect the quality of the code offering advice on avoiding writing crappy code.