Definite Guide to Grails, 2006

Definite Guide to Grails, 2006

CYAN YELLOW MAGENTA BLACK PANTONE 123 CV EMPOWERING PRODUCTIVITY FOR THE JAVA™ DEVELOPER THE EXPERT’S VOICE® IN JAVA™ TECHNOLOGY Companion eBook Available The Definitive Guide to Grails The Definitive 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 Guide to 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 The Definitive Guide to 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. Grails 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. Grails 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. Join online discussions: forums.apress.com Graeme Rocher FOR PROFESSIONALS Grails Project Lead Learn from Grails project founder and lead how to leverage BY PROFESSIONALS™ Grails, the open source, lightweight web application Companion eBook framework, using the dynamic Groovy scripting language. THE APRESS JAVA™ ROADMAP Pro Wicket The Definitive Guide to Beginning POJOs See last page for details Grails on $10 eBook version Beginning Spring 2 Pro Spring Rocher SOURCE CODE ONLINE Graeme Keith Rocher www.apress.com ISBN 1-59059-758-3 53999 Foreword by Guillaume Laforge, Groovy Project Manager, US $39.99 and Dierk Koenig Shelve in Java Programming User level: Intermediate–Advanced 6 89253 59758 3 9 781590 597583 this print for content only—size & color not accurate spine = 0.893" 384 page count Rocher_758-3FRONT.fm Page i Monday, November 13, 2006 1:56 PM The Definitive Guide to Grails ■■■ Graeme Keith Rocher Rocher_758-3FRONT.fm Page ii 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 [email protected], 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 [email protected], 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 iii 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 iv Monday, November 13, 2006 1:56 PM Rocher_758-3FRONT.fm Page v Monday, November 13, 2006 1:56 PM 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 v Rocher_758-3FRONT.fm Page vi Monday, November 13, 2006 1:56 PM Rocher_758-3FRONT.fm Page vii Monday, November 13, 2006 1:56 PM 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 vii Rocher_758-3FRONT.fm Page viii 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 . ..

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    383 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us