Table of Contents

Copyright

Brief Table of Contents

Table of Contents

List of Figures

List of Tables

List of Listings

Foreword

Preface

Acknowledgments

About this Book

About the Title

About the Cover Illustration

1. Introducing Grails

Chapter 1. Grails in a hurry...

1.1. Why Grails?

1.1.1. First there was Rails...

1.1.2. Why Grails changed the game

1.1.3. Big idea #1: Convention over Configuration

1.1.4. Big idea #2: agile philosophy

1.1.5. Big idea #3: rock-solid foundations

1.1.6. Big idea #4: scaffolding and templating

1.1.7. Big idea #5: Java integration

1.1.8. Big idea #6: incredible wetware

1.1.9. Big idea #7: productivity ethos

1.2. Getting set up

1.3. Our sample program: a Web 2.0 QOTD

1.3.1. Writing your first controller

1.3.2. Writing stuff out: the view

1.3.3. Adding some style with Grails layouts

1.4. Creating the domain model

1.4.1. Configuring the data source

1.4.2. Exploring database operations

1.5. Adding UI actions

1.5.1. Scaffolding: just add rocket fuel

1.5.2. Surviving the worst case scenario

1.6. Improving the architecture

1.6.1. Your first Grails test case

1.6.2. Going Web 2.0: Ajax-ing the view

1.6.3. Bundling the final product: creating a WAR file

1.6.4. And 55 lines of code later

1.7. Summary and best practices

Chapter 2. The Groovy essentials

2.1. An introduction

2.1.1. Let’s play with Groovy!

2.1.2. Some basic differences from Java

2.1.3. Some new operators

2.2. Exploring types

2.2.1. Looking at basic types

2.2.2. Syntax sugar for lists, maps, and ranges

2.3. Time-saving features

2.3.1. Who needs semicolons?

2.3.2. Native regular expressions

2.3.3. Property notation

2.3.4. Anything in Java that’s not in Groovy?

2.4. Expert Groovy

2.4.1. Discovering closures

2.4.2. Programming dynamically

2.4.3. The Groovy JDK

2.4.4. Creating and parsing XML the easy way

2.5. Summary and best practices

2. Core Grails

Chapter 3. Modeling the domain

3.1. Hubbub: starting our example application

3.1.1. Domain-driven design

3.1.2. Hubbub kick-start: from 0 to first hit

3.1.3. Introducing GORM (Grails object relational mapping)

3.2. Your first domain class object

3.2.1. Saving and retrieving users via tests

3.2.2. Updating user properties

3.2.3. Deleting users

3.3. Validation: stopping garbage in and out

3.3.1. Standard validators

3.3.2. Custom validation with regular expressions

3.3.3. Cross-field validation tricks

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

3.4.1. One-to-one relationships

3.4.2. One-to-many relationships

3.4.3. Many-to-many relationships

3.4.4. Self-referencing relationships

3.5. Summary and best practices

Chapter 4. Putting the model to work

4.1. Creating instant UIs with scaffolding

4.1.1. Scaffolding Hubbub’s domain classes

4.1.2. Scaffolding and validation

4.1.3. Customizing error messages

4.1.4. Managing relationships via scaffolds

4.1.5. Tweaking scaffold layouts with CSS

4.1.6. What can’t you do with dynamic scaffolds?

4.1.7. Static scaffolding: generating and customizing scaffold code

4.1.8. Customizing scaffolding templates: building your own UI generator

4.2. Groovy querying with dynamic finders and Query by Example

4.2.1. Implementing a basic search form

4.2.2. The many faces of dynamic finders

4.2.3. Tuning dynamic finders with eager and lazy fetching

4.2.4. When dynamic finders don’t deliver

4.2.5. Introducing Query by Example (QBE)

4.2.6. Getting dynamic with list(), listOrderBy(), and countBy()

4.3. More sophisticated query options

4.3.1. With great power: criteria querying

4.3.2. Dynamic queries with criteria

4.3.3. Creating a tag cloud using report-style query projections

4.3.4. Using HQL directly

4.4. Bootstrapping reference data

4.5. Summary and best practices

Chapter 5. Controlling application flow

5.1. Controller essentials

5.1.1. Implementing a timeline for Hubbub

5.1.2. Adding new posts

5.1.3. Exploring scopes

5.1.4. Handling default actions

5.1.5. Working with redirects

5.2. Services: making things robust and maintainable

5.2.1. Implementing a PostService

5.2.2. Wiring our PostService to our PostController

5.3. Data binding

5.3.1. Binding to an existing object

5.3.2. Whitelist and blacklist bind params

5.3.3. Complex forms: binding multiple objects

5.3.4. Error handling

5.4. Command objects

5.4.1. Handling custom user registration forms

5.4.2. Participating in injection

5.5. Working with images

5.5.1. Handling file uploads

5.5.2. Uploading to the filesystem

5.5.3. Rendering photos from the database

5.6. Intercepting requests with filters

5.6.1. Writing your first filter

5.6.2. Filter URL options

5.7. Creating custom URL mappings

5.7.1. myHubbub: rolling your own permalinks

5.7.2. Optional variables and constraints

5.7.3. Handling response codes

5.7.4. Mapping directly to the view

5.7.5. Wildcard support

5.8. Summary and best practices

Chapter 6. Developing tasty views, forms, and layouts

6.1. Understanding the core form tags

6.1.1. A handful of essential tags

6.1.2. A pocketful of link tags

6.1.3. A tour of the form tags

6.1.4. Adding pagination to the timeline

6.2. Extending views with your own tags

6.2.1. Simple tags

6.2.2. Logical tags

6.2.3. Iteration tags

6.2.4. Calling one tag from another

6.3. Adding delicious layouts

6.3.1. Introducing SiteMesh

6.3.2. Standardizing page layouts

6.3.3. Fragment layouts with templates

6.3.4. Adding skinning

6.3.5. Implementing navigation tabs

6.4. Applying Ajax tags

6.4.1. Choosing a JavaScript library

6.4.2. Essential Ajax form remoting

6.4.3. Sizzle++: going further with animation and effects

6.5. Summary and best practices

Chapter 7. Building reliable applications

7.1. Why should we test software?

Test-Driven Development

7.2. Unit testing

7.2.1. Testing domain classes

7.2.2. Testing services

7.2.3. General mocking in Grails

7.2.4. Testing controllers

7.2.5. Testing tag libraries

7.3. Integration testing

7.3.1. Filling the gaps

7.3.2. When only an integration test will do

7.4. Functional testing

7.4.1. Introducing the Functional Test plugin

7.4.2. Other testing tools

7.5. Summary and best practices

3. Everyday Grails

Chapter 8. Using plugins: adding Web 2.0 in 60 minutes

8.1. Taking advantage of others’ hard work

8.1.1. Finding plugins

8.1.2. Installing plugins

8.2. Adding charts and graphs

8.2.1. Installing the Google Chart plugin

8.2.2. Creating your first chart

8.2.3. What’s the story with dataType?

8.2.4. Bar charts: setting custom colors and gridlines

8.2.5. Line charts: handling multiple datasets and line styles

8.2.6. Intranet charts: Google Chart without Google

8.3. Adding mail support

8.3.1. Sending mail inline

8.3.2. Using a view as your mail body

8.4. Full-text search: rolling your own search

8.4.1. Making objects searchable

8.4.2. Highlighting hit terms

8.4.3. Implementing pagination

8.4.4. Customizing what gets indexed

8.4.5. Query suggestions: did you mean “Grails”?

8.4.6. Searching across relationships

8.5. GrailsUI makeover

8.5.1. Adding tooltips

8.5.2. Implementing rich-text editing

8.5.3. Implementing calendar-style dates

8.5.4. Introducing autocomplete

8.6. Summary and best practices

Chapter 9. Wizards and workflow with webflows

9.1. What is a webflow?

9.1.1. Writing your first flow: a checkout wizard

9.1.2. Anatomy of a flow state

9.2. Working with webflows

9.2.1. Flow scope: better than Flash scope, cheaper than session scope

9.2.2. Strategies for binding and validation

9.2.3. Making decisions programmatically with action states

9.3. Advanced webflows

9.3.1. Flow-scoped services

9.3.2. Subflows and conversations

9.4. Testing webflows

9.4.1. Handling input parameters

9.4.2. Testing subflow transitions

9.4.3. Testing flow termination

9.5. Summary and best practices

Chapter 10. Don’t let strangers in—security

10.1. Why security matters

10.2. Protecting against malicious intent

10.2.1. Validate all your inputs

10.2.2. Escape all your outputs

10.2.3. SSL, encryption, and message digests

10.2.4. Don’t give away information

10.3. Access control

10.3.1. Getting started with Spring Security

10.3.2. Protecting URLs

10.3.3. Getting hold of the current user

10.3.4. Using a custom login page

10.3.5. Testing access control

10.4. Further exploration of Spring Security

10.4.1. Adding user registration

10.4.2. Tightening restrictions on access

10.4.3. Other authentication options

10.5. Summary and best practices

Chapter 11. Remote access

11.1. Using a RESTful solution

11.1.1. Your first steps in REST

11.1.2. Serializing and deserializing domain instances

11.1.3. Testing the API

11.2. Negotiating the representation

11.2.1. REST and the params property

11.2.2. Handling multiple response formats

11.2.3. How the response format is decided

11.3. REST in practice

11.3.1. Keeping the API stable

11.3.2. Applying the theory

11.4. Operation-oriented remoting

11.4.1. The Remoting plugin

11.4.2. Comparing the remoting protocols

11.4.3. Web Services via SOAP

11.5. Summary and best practices

Chapter 12. Understanding messaging and scheduling

12.1. A hitchhiker’s guide to messaging

12.1.1. Learning to think in async: what are good messaging candidates?

12.1.2. Messaging terminology: of producers, consumers, topics, and queues

12.1.3. Installing and configuring the JMS plugin

12.2. Using the Grails JMS plugin

12.2.1. Our killer Hubbub feature: IM integration with Jabber

12.2.2. Sending JMS messages

12.2.3. Reading the queue

12.3. Grails scheduling

12.3.1. Writing a daily digest job

12.3.2. Fine-grained scheduling with cron

12.4. Advanced scheduling

12.4.1. Dealing with re-entrance and stateful jobs

12.4.2. Pausing and resuming stateful jobs programmatically

12.4.3. Persistence and clustering

12.5. Summary and best practices

4. Advanced Grails

Chapter 13. Advanced GORM kung fu

13.1. Domain model kung fu

13.1.1. Exploring inheritance options

13.1.2. Embedding domain classes

13.1.3. Using maps for quick and dirty (or cheap and cheerful) tables

13.1.4. Exploring domain model events

13.2. Caching kung fu: moving from 2 users to 2^10

13.2.1. Hibernate settings: should you use the second-level cache?

13.2.2. Cache configuration

13.2.3. Caching individual domain classes

13.2.4. Enough talk, let’s profile

13.2.5. Improving performance with indexed fields

13.2.6. What about query caching?

13.2.7. JNDI? That’s so old school...

13.3. Legacy integration kung fu: dealing with multiple data sources

13.4. Dealing with difficult legacy databases

13.4.1. Recycling Hibernate mappings

13.4.2. Using GORM DSL to access existing database table structures

13.5. Summary and best practices

Chapter 14. Spring and transactions

14.1. Spring and Grails

14.1.1. A conventional approach

14.1.2. Creating and defining your own beans

14.2. Using transactions with GORM

14.2.1. Easy transactions with services

14.2.2. Transactions, the session, and me

14.2.3. Fine-grained transactions

14.3. Summary and best practices

Chapter 15. Beyond compile, test, and run

15.1. The Grails build system

15.1.1. Packaging an application

15.1.2. Going it alone: how to create a dist command

15.1.3. Deployment

15.2. Build integration—not for the hobbyist

15.2.1. Ant

15.2.2. Maven

15.3. Coping with a changing data model

15.3.1. Schema migration with Hibernate

15.3.2. Intelligent migration with Autobase

15.4. Summary and best practices

Chapter 16. Plugin development

16.1. Creating your first plugin

16.1.1. Are you sure it’s not an application?

16.1.2. Controllers, views, and other artifacts

16.2. Publishing your plugin

16.2.1. Testing plugins

16.2.2. Releasing the plugin into the wild

16.3. Integrating with Grails

16.3.1. Enhancing artifacts with dynamic methods

16.3.2. Dealing with class reloading

16.3.3. Leveraging Spring

16.3.4. Playing with servlets and filters

16.3.5. Augmenting the available Grails commands

16.4. Summary and best practices

Index

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

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