Contents

Foreword

About the Authors

About the Technical Reviewer

Acknowledgments

Introduction


CHAPTER 1      Introduction to Groovy

                             Groovy Language Features

                             Groovy Installation

                             Groovy by Example

                                   Converting Java to Groovy

                                   Converting a JavaBean to a GroovyBean

                                   Simplifying the Code

                                   Using Groovy Collection Notation and Closure

                                   Getting Rid of Main()

                             Summary

CHAPTER 2      Groovy Basics

                             Scripts

                                   Using Script Functions

                                   Compiling Groovy

                                   Running Groovy

                             Assertions

                             Strings

                                   String Interpolation

                                   Multiline Strings

                                   Slashy Strings

                             Methods and Closures

                                   Methods

                                   Closures

                             Collections

                                   Lists

                                   Ranges

                                   Sets

                                   Arrays

                                   Maps

                             Regular Expressions

                                   Groovy Regular Expression Operators

                                   Common Uses of Regular Expressions

                             Operators

                                   Operator Overloading

                                   Specialized Operators

                             Summary

CHAPTER 3      More Advanced Groovy

                             Groovy Unit Testing

                             Working with XML

                                   Writing XML with Java

                                   Groovy Builders

                                   Writing XML with Groovy MarkupBuilder

                                   Reading XML with XmlSlurper

                             Generating Text with Templates

                             Expandos

                             Meta Object Protocol

                             Domain-Specific Languages

                             Summary

CHAPTER 4      Introduction to Grails

                             What Is Grails?

                                   Grails Features

                                   Integrated Open Source

                             Grails Architecture

                             Installing Grails

                             Collab-Todo Application

                             Getting Started with Scaffolding

                             Understanding the Scaffolding Process

                                   Creating the Application

                                   Running the Application

                                   Creating a Domain Class

                                   Implementing Integration Tests

                                   Running the Test Harness

                                   Implementing a Domain Class

                                   Creating the Controller

                                   Finishing the Remaining Domain and Controllers

                                   Creating Domain Relationships

                             Summary

CHAPTER 5      Building the User Interface

                             Starting with the End in Mind

                                   Creating the Footer

                                   Creating the Topbar

                                   Adding More Look and Feel

                                   Grails Tags

                             Making the Topbar Functional

                                   The Login View

                                   The login Action

                                   Handling the Login and Logout Actions

                             Testing

                                   Integration Testing Using JUnit

                                   Functional Testing Using Canoo WebTest

                             Externalizing Strings

                             Errors and Validation

                             Flash and Flash Messages

                             Controlling the Application

                                   Controlling Users

                                   Controlling Categories

                             Creating an Audit Log Using Action Interceptors

                             Using Filters

                             Summary

CHAPTER 6      Building Domains and Services

                             GORM

                             Collab-Todo's Domain

                             Creating Domain Objects

                                   Basic Domain Creation

                                   Creating Relationships

                                   Overwriting Default Settings

                             Validation

                                   Constraints

                                   Calling the Validator

                                   Validation Messages

                             Querying the Database

                                   GORM's CRUD Support

                                   Creating Queries

                             Database Migration

                                   The dbmigrate Plug-In

                                   The LiquiBase Plug-In

                             Services

                                   Creating a Service

                                   Calling the Service

                                   Injecting into the Service

                                   Initializing the Service

                                   Setting a Bean to Be Transactional

                                   Service Context Available in the Service

                             Summary

CHAPTER 7      Security in Grails

                             What Is Security?

                                   Authentication

                                   Access Control

                             An Overview of Grails Security Solutions

                             Custom Security Implementation

                                   Registering a User

                                   Logging In and Out

                                   Securing the Controllers

                             JSecurity

                                   JSecurity Installation

                                   JSecurity Domain Classes

                                   JSecurity Domain Data

                                   JSecurity Usage

                             CAS

                                   CAS Installation

                                   CAS Configuration

                                   CAS Usage

                             Spring Security (aka Acegi Security)

                                   Acegi Installation

                                   Acegi Domain Classes

                                   Acegi Domain Data

                                   Acegi Domain Customization

                                   Acegi Security Usage

                             Summary

CHAPTER 8      Web 2.0—Ajax and Friends

                             Advanced Presentation Components

                                   Adding Rich-Text Capabilities

                                   Adding Search Capabilities

                                   Allowing File Uploads

                                   Adding Mail Services

                             Tag Libraries

                                   Creating the Tag Library

                                   Referencing the Tag Library

                             Ajax in Grails

                                   Using Ajax Frameworks in Grails

                                   Dynamic Rendering of Data

                                   Editing a Field in Place

                                   Using the Autocomplete Feature

                             RSS Feeds

                             Summary

CHAPTER 9      Web Services

                             RESTful Web Services

                             RESTful in Grails

                                   URL Mapping

                                   RestController

                             Summary

CHAPTER 10     Reporting

                             The Report

                             Overview of the Reporting Function

                             Reporting Tools

                                   Overview

                                   Installing JasperReports and iReports

                             Creating the To-Do Report

                                   Defining the Data Source

                                   Using iReports

                                   Enhancing the Report

                                   Compiling the Report

                             The Report Tag

                                   Tag Library Overview

                                   Creating the Tag

                             The ReportController and the ReportService

                             Tying It All Together

                                   Gathering the Report Data

                                   Adding the Report Tag to the Application

                             The Report List

                             An Alternate Approach

                             Summary

CHAPTER 11     Batch Processing

                             Installing the Quartz Plug-in

                             Creating a Job

                             Building a Batch-Reporting Facility

                                   Creating a Nightly Reporting Job

                                   Retrieving the User's To-Dos

                                   Invoking the Report Service

                                   Invoking the E-Mail Service

                             Summary

CHAPTER 12     Deploying and Upgrading

                             Deploying Grails Applications

                                   Using Environments

                                   Understanding Grails Configurations

                                   Packaging the Application for Deployment

                                   Deploying to an Application Server

                             Automating Tasks with Gant

                             Upgrading Grails Applications

                             Summary

CHAPTER 13     Alternative Clients

                             Overview

                             Setup

                             Command-Line Scripts

                                   Command-Line Overview

                                   Reading To-Do Items

                                   Creating To-Do Items

                                   Deleting To-Do Items

                                   Updating To-Do Items

                                   Command-Line Script Summary

                             Rich Groovy Client

                                   Overview

                                   Options, Alternatives, and Considerations

                                   Builder Overview

                                   Creating the Main Module

                                   Creating the Controller Module

                                   Creating the View

                                   HTTP Utilities (Get, Put, Post, and Delete)

                             Summary


Index

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset