Mike has posted 2 posts at DZone. View Full User Profile

The Definitive Guide to Grails

06.17.2009
| 8089 views |
  • submit to reddit
Published by: Apress
ISBN: 9781590597583

Reviewer Ratings

Relevance:
4

Readability:
4

Overall:
4

Buy it now

One Minute Bottom Line

I pre-ordered the book because I wanted to get my hands on a Grails 1.1 book as soon as possible.  I am a big fan of the Manning Press In Action books but did not want to wait until June in order to get a copy of Grails In Action.   I am very happy with my decision to buy and read this book.  I would recommend it to anyone interested in learning Grails. 

Who better to learn Grails from than Graeme Rocher and Jeff Brown?

Review

Chapter 1 The Essence of Grails

The first chapter provides a very high-level overview of Grails.   The chapter leads you through setting up the basics for the gTunes application, which will be updated and enhanced as you progress through the book.

Chapter 2 Getting Started with Grails

The second chapter starts to pickup the pace.   In this chapter you create the Song domain object for the gTunes application.   This domain object provides the basis for discussions about the CRUD functionality provided by Grails and GORM.  The concepts of dynamic and static scaffolding are introduced in this chapter.  Next, you generate a controller and views for the Song domain object.  Lastly, the book provides some explanations about environments (prod, test and dev) along with explanations about configuring data sources using DataSource.groovy.

Chapter 3 Understanding Domain Classes

Chapter 3 provides more details on domain classes, field persistence, transient fields, inheritance, built-in validators and custom validators.  This chapter starts the discussion about domain object relationships.  Relationships will be very familiar to those readers already familiar with Hibernate but the Grails learning curve for this is so much shorter!

Chapter 4 Understanding Controllers

Chapter 4 provides details on controllers within Grails.  The chapter begins with some discussion about logging and accessing HTTP request attributes and then moves on to explain controller scopes (request, flash, session and servletContext).   Next, the chapter discusses most of the common tasks encountered by controllers:  data binding, validating input, creating models and rendering views.   The last part of the chapter enhances the gTunes application creating a User domain object, creating a login form/view and implementing some controller methods to support user registration and login for gTunes.

 

Chapter 5 Understanding Views

This chapter covers Grails views.  For those already familiar with JSP, JSTL and EL, this chapter will feel like a review, except that the views are GSPs (Groovy Server Pages) and not JSPs.  Grails has done more of the work for you with their built-in tags, like the <g:collect> tag which allows you to collect properties of objects within a collection or the <g:findAll> tag which allows you to iterate over only those values that meet a certain criteria.   Paginating views, one of the nicer features included by Grails, is covered as part of this chapter.

Chapter 6 Mapping URLs

This is one of the smallest chapters in the book.  It helps explain how some of the ‘convention over configuration’ is handled, especially the mapping of Grails URLs and it provides examples of how to make additional changes to the URLs to add additional parameters and including wildcards in the mapping.

Chapter 7 Internationalization

The shortest chapter of the book shows the user where in Grails to define the localized messages and the appropriate tags to be used in the views to retrieve those localized messages.

Chapter 8 Ajax

Chapter 8 walks the reader through the process of updating the gTunes application to include some AJAX functionality.  Adding AJAX to a Grails application is very easy thanks to the built-in support provided by the framework.  By default, Grails supports both the Prototype library and the Scriptaculous effects library.

Chapter 9 Creating Web Flows

Grails web flows are built on the Spring Web Flow project using a Groovy domain-specific language (DSL) for the flow creation.  This chapter implements a rather lengthy web flow for the gTunes application.  Being a new Grails user, I would have preferred a shorter and less complicated example web flow before launching in to the implementation completed in this chapter.

Chapter 10 GORM

GORM (Grails Object Relation Mapping) covers the many of the same topics needed when you work with Hibernate, except here you learn to do it the Grails way. Configuring GORM, creating criteria queries, HQL, transaction support and performance tuning are all covered.

Chapter 11 Services

This chapter provides insight into how Grails uses Spring and Dependency Injection to provide a ‘service layer’ to Grails.   Transaction management is also touched on.  

Chapter 12 Integrating Grails

This chapter covers some basic Grails configuration, and then introduces Gant, and integration with Ant and dependency resolution with Ivy.  Also covered is integration with Cobertura, Hudson, IDE integration, E-mail servers and Quartz.

Chapter 13 Plugins

This chapter is a tour through plugins, starting with how to list the plugins you currently have installed, how to install new plugins and then how to develop your own plugin.  The final sections of the chapter develop a couple plugins for the gTunes application.

Chapter 14 Security

The authors mention that rolling your own security implementation would be “rather wasteful give the abundance of security frameworks available for Grails”.  The list of security plugins includes Acegi (Spring Security), Authentication and JSecurity.   Considering that Grails is built on top of the Spring framework, it was surprising to me that the rest of the chapter was spent implementing the JSecurity plugin rather than the Acegi plugin.

Chapter 15 Web Services

When the topic of Web Services comes up, the discussion generally centers around REST vs SOAP.    Grails provides REST support out of the box and seems to be a far better fit for Grails than SOAP.   REST support is added to the gTunes application along with the ability to create RSS and ATOM feeds and finally a short discussion on implementing SOAP using the XFire plugin.

Chapter 16 Leveraging Spring

Chapter 16 shows how to leverage Spring using the Spring DSL provided by Grails.   The Spring DSL is used to update the gTunes application to add JMS integration with ActiveMQ.

Chapter 17 Legacy Integration with Hibernate

Unless you are building a new application from scratch using Grails, this chapter is very helpful, covering even more examples of how to integrate with Hibernate and your legacy databases.  The examples show the mapping statements along with sample tables to help complete the picture.  Hibernate XML and EJB3-compliant mappings are touched on lightly.

Appendix The Groovy Language

The appendix provides a high level overview of the Groovy Language to help refresh the concepts of Groovy for the reader. 

Published at DZone with permission of its author, Mike Miller.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags: