definite guide to grails, 2006

383 264 0
definite guide to grails, 2006

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

this print for content only—size & color not accurate spine = 0.893" 384 page count EMPOWERING PRODUCTIVITY FOR THE JAVA ™ DEVELOPER US $39.99 Shelve in Java Programming User level: Intermediate–Advanced Rocher Grails THE EXPERT’S VOICE ® IN JAVA ™ TECHNOLOGY Graeme Keith Rocher Foreword by Guillaume Laforge, Groovy Project Manager, and Dierk Koenig The Definitive Guide to Grails CYAN MAGENTA YELLOW BLACK PANTONE 123 CV ISBN 1-59059-758-3 9 781590 597583 53999 6 89253 59758 3 Companion eBook Available Learn from Grails project founder and lead how to leverage Grails, the open source, lightweight web application framework, using the dynamic Groovy scripting language. www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version forums.apress.com FOR PROFESSIONALS BY PROFESSIONALS ™ Join online discussions: THE APRESS JAVA ™ ROADMAP Pro SpringBeginning Spring 2 Pro Wicket The Definitive Guide to Grails Beginning POJOs The Definitive Guide to Grails Dear Reader, As modern web application developers, most of us have experienced one or many of the so-called web application frameworks that promise much, but often deliver so little. The frustration of verbose configuration and anemic APIs has led many, particularly in the Java ™ community, in search of greener fields. The aim of this book is to introduce one of those greener fields that is not so far from home. In fact, its roots are very much embedded in the Java platform that we all know and love. Grails could well be the web application framework that you’ve been searching for. Here, I provide you with all the information that you need to get productive quickly. You will learn how to use the Groovy language with Grails to rapidly prototype applications, develop dynamic tag libraries, create rich domain models, and provide reusable services. If you’re from a background of building applications with existing Java frameworks, such as Spring, Hibernate, and Quartz, you’ll be able to build on that knowledge, because Grails leverages each of these well- known frameworks to provide a full stack experience. If you’re not, Grails shields you from the technicalities of those framework APIs, leaving you to focus on what’s important: the business logic in your application. I wrote this book to spread the news that there are robust, dynamic alterna- tives to traditional Java web application frameworks, and to show you how you can use dynamic and statically typed code that will complement one another where appropriate. Groovy is an incredibly powerful language, but until recently much of its power was largely undocumented. The development of Grails provides a shining example of what Groovy is capable of when its full range of features is harnessed. Graeme Rocher Grails Project Lead The Definitive Guide to The Definitive Guide to Grails ■■■ Graeme Keith Rocher Rocher_758-3FRONT.fm Page i Monday, November 13, 2006 1:56 PM The Definitive Guide to Grails Copyright © 2006 by Graeme Keith Rocher All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-59059-758-3 ISBN-10 (pbk): 1-59059-758-3 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems Inc. in the United States and other countries. Apress Inc. is not affiliated with Sun Microsystems Inc., and this book was written without endorsement from Sun Microsystems Inc. Lead Editor: Steve Anglin Technical Reviewers: Guillaume Laforge, Dierk König Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Gennick, Jonathan Hassell, James Huddleston, Chris Mills, Matthew Moodie, Dominic Shakeshaft, Jim Sumser, Keir Thomas, Matt Wade Project Manager: Kylie Johnston Copy Edit Manager: Nicole Flores Copy Editors: Jennifer Whipple, Ami Knox Assistant Production Director: Kari Brooks-Copony Production Editor: Lori Bring Compositor: Susan Glinert Proofreader: Nancy Sixsmith Indexer: Joy Dean Lee Artist: Kinetic Publishing Services, LLC Cover Designer: Kurt Krames Cover Art: Arthur Smit Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer-sbm.com, or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail info@apress.com, or visit http://www.apress.com. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com in the Source Code/Download section. Rocher_758-3FRONT.fm Page ii Monday, November 13, 2006 1:56 PM To my amazing wife, Birjinia, for your love and support, and for managing to live with a bit of a geek. Maitia zatut. Rocher_758-3FRONT.fm Page iii Monday, November 13, 2006 1:56 PM Rocher_758-3FRONT.fm Page iv Monday, November 13, 2006 1:56 PM v Contents at a Glance Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvi About the Technical Reviewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix ■CHAPTER 1 The Search for the Holy Grail(s) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 ■CHAPTER 2 The Groovy Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 ■CHAPTER 3 The Grails Project Infrastructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 ■CHAPTER 4 The Application Domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 ■CHAPTER 5 Scaffolding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 ■CHAPTER 6 Testing, Testing, Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 ■CHAPTER 7 Grails Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 ■CHAPTER 8 Groovy Server Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 ■CHAPTER 9 Ajax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 ■CHAPTER 10 Services and Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 ■CHAPTER 11 Java Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 ■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 Rocher_758-3FRONT.fm Page v Monday, November 13, 2006 1:56 PM Rocher_758-3FRONT.fm Page vi Monday, November 13, 2006 1:56 PM vii Contents Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvi About the Technical Reviewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix ■CHAPTER 1 The Search for the Holy Grail(s) . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Trouble in Paradise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 The Arrival of Web 2.0 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 The Power of Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Grails: The Story So Far . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Java Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Simplicity and Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Lessons Learned. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Why You Should Be Interested in Grails . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Getting Started with Grails . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Running the Targets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 The Obligatory “Hello World!” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 The Unit Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 ■CHAPTER 2 The Groovy Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Groovy and Java: A Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 What’s the Same? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 What’s Different? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 The Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Declaring Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Language-Level Assertions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Groovy Strings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Closures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Lists and Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Expando Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Ranges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Rocher_758-3FRONT.fm Page vii Monday, November 13, 2006 1:56 PM viii ■CONTENTS Groovy Power Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Everything Is an Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Metaprogramming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Understanding Builders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 ■CHAPTER 3 The Grails Project Infrastructure . . . . . . . . . . . . . . . . . . . . . . . . . 37 Overview of a Grails Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Grails and the MVC Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 The M in MVC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 The V in MVC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 The C in MVC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Beyond MVC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Being Environmentally Friendly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Data Source Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Supported Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Configuring a Custom Dialect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Bootstrapping a Grails Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Configuring Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Enabling SQL Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Logging and Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 The Grails Command-Line Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Running on a Different Port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Packaging a WAR Archive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Using the Grails Console and Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 Using the Command-Line Shell. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 The Grails Console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 IDE Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Installing the Groovy-Eclipse Plug-in . . . . . . . . . . . . . . . . . . . . . . . . . 55 Importing a Grails Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Running the Grails Application from Eclipse . . . . . . . . . . . . . . . . . . . 58 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 ■CHAPTER 4 The Application Domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Simplified ORM with Grails Object-Relational Mapping (GORM) . . . . . . . 61 GORM Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Making Properties Optional . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Relationships with GORM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Rocher_758-3FRONT.fm Page viii Monday, November 13, 2006 1:56 PM ■CONTENTS ix Performing CRUD Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Creating Bookmarks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Reading a Bookmark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Updating the Bookmark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Deleting Bookmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Querying the Domain Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Basic Retrieval with get and exists. . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Listing, Sorting, and Counting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 Querying with Dynamic Finders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Querying with HQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Querying by Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Querying with Criteria. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Mapping Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Validating the Domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 Applying Domain Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Validating Against Constraints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Defining Custom Constraints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Performing Updates Revisited. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 ■CHAPTER 5 Scaffolding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 Dynamic Scaffolding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 Create Operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 Read Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Update Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Delete Operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 Overriding CRUD Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 Customizing Fields with Constraints. . . . . . . . . . . . . . . . . . . . . . . . . 103 Static Scaffolding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 Generating a Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 Generating Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 ■CHAPTER 6 Testing, Testing, Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 Writing Effective Unit Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 Using the assert Keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 Using Test Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 Exploring GroovyTestCase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 Testing in Practice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Rocher_758-3FRONT.fm Page ix Monday, November 13, 2006 1:56 PM [...]... GRAILS_HOME variable to your profile file within your home directory (i.e., cd ~) Rocher_758-3C01.fm Page 9 Wednesday, October 18, 2006 10:13 AM CHAPTER 1 ■ THE SEARCH FOR THE HOLY GRAIL(S) 4 In addition, to get the Grails scripts to work from a terminal or command window you need to add the bin directory within Grails to your PATH that will make the Grails scripts visible to the window To do this, take... time required to deploy a web application To compound these already significant factors, testing rich application flows started to become problematic With much of the state held on the client, having to reload your browser due to an application restart could set you several steps back in any given use case The reality was that the frameworks needed to adapt Adapting is not the easiest thing to achieve... November 13, 2006 1:56 PM Acknowledgments F irst and foremost, I’d like to thank my wife, Birjinia, for her beauty, wisdom, and continued love and support You are the best Also, to my kids, Alex and Lexeia, who wanted to extract me from my laptop on many occasions while I was writing this book, but had the patience to let me complete it Thanks to my mum, my father (I miss you), my sister, and to all of... models, views, and controllers to cleanly separate concerns Nevertheless, to display a simple “Hello World!” we only need to be concerned with controllers for the moment Controllers are core to any MVC framework, Grails being no different; and in fact the only way to handle a request in Grails is to create a controller Out of convenience, Grails provides a target to do just this To create a controller, run... optimized for the JVM All of this amounts to too much to just walk away from to embrace the latest hot framework The Java industry is a huge multibillion dollar behemoth that encompasses not only web applications but server applications, desktop applications, smart cards, handheld devices, mobile phones, set-top boxes—this list could go on forever Conferences dedicated to Java are some of the largest technology... painless a learning experience as possible The creators of Groovy recognized that for Java developers to be truly productive when using a dynamic language it should not require a huge mental shift to go from language to language Thanks to this, Groovy uses a strikingly similar syntax and the same APIs available to you in the JDK Groovy compiles directly down to byte code, thus ensuring that it also shares... frameworks? No, on the contrary they’re designed to work with Java To embrace it To have Java at their very core Grails is Java through and through, and it allows you to pick and choose which features to implement with dynamic typing, and which to better place in the safer hands of static typing Grails exists out of the acknowledgment that there is never only one tool for the job Grails is about providing... Wednesday, October 18, 2006 10:13 AM 10 CHAPTER 1 ■ THE SEARCH FOR THE HOLY GRAIL(S) It may be interesting to note at this point that Grails uses the Apache Ant (http://ant apache.org) build system to power these targets, and throughout the book I will be referring to them as targets (as opposed to commands or operations) ■Note Ant is supported by every modern IDE on the market and is the ubiquitous build... have contributed to Grails over the past year or so, I would like to thank Steven Devijver of Interface21 and Guillaume again for joining me in getting Grails going when it was just a bunch of ideas in an e-mail To Marc Palmer for providing a voice of reason, intelligent debate, and continued valuable contribution to Grails To Micha Kujszo for his contributions toward Quartz support To Dierk again and... actions that they delegate to (another thing you’ll learn about later in the book) Just to provide some clarity, the effect you want to achieve is depicted in the screenshot in Figure 1-3 Figure 1-3 The “Hello World!” response In order to create the response depicted in Figure 1-3, you’re going to make some modifications to the HelloController and add a new action called world to it Actions are both closures . Definitive Guide to The Definitive Guide to Grails ■■■ Graeme Keith Rocher Rocher_758-3FRONT.fm Page i Monday, November 13, 2006 1:56 PM The Definitive Guide to. information that you need to get productive quickly. You will learn how to use the Groovy language with Grails to rapidly prototype applications, develop

Ngày đăng: 20/03/2014, 15:39

Mục lục

    The Definitive Guide to Grails

    Chapter 1 The Search for the Holy Grail(s)

    Chapter 2 The Groovy Language

    Chapter 3 The Grails Project Infrastructure

    Chapter 4 The Application Domain

    Chapter 6 Testing, Testing, Testing

    Chapter 8 Groovy Server Pages

    Chapter 10 Services and Jobs