1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Grails: A Quick-Start Guide docx

231 3,8K 1

Đ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

Thông tin cơ bản

Định dạng
Số trang 231
Dung lượng 6,64 MB

Nội dung

What Readers Are Saying About Grails: A Quick-Start Guide This book, like Grails, is common sense distilled You’ll be productive in Grails in no time Scott Davis Founder, ThirstyHead.com This book stands heads and shoulders above other Groovy and Grails books available today Dave’s practical, hands-on approach will teach you the nuts and bolts of the language and framework and then lead you through a project, step-by-step This mix of instruction and practice is the perfect introduction to both Groovy and Grails Jared Richardson Consultant, Agile Artisans.com The Grails web framework is all about productivity, and so is Grails: A Quick-Start Guide Dave Klein builds a serious application throughout the chapters, as if you were working with a colleague teaching you new technology This guide will get you productive in hours, not weeks, and thanks to Dave’s humor, you’re really going to enjoy learning Grails If you need to dive into Grails for your next project, this book is for you! Guillaume Laforge Groovy project manager, SpringSource Dave Klein’s book is an enjoyable read that presents an efficient path to get from Grails novice to productive programmer Anyone developing a web application to run on a JVM should read this book Steven Harris Director of engineering, Terracotta This book was an excellent guide for me as a first-time user of Grails as well as Groovy Building an entire project while learning is a big asset: it is one thing to read and learn; it is another to learn by example The book presents the subject matter creatively and simplifies it It is definitely a recommended guide to those beginners who are ready to take on a challenge with Grails and Groovy Amer Ghumrawi Programmer/analyst, WinWholesale, Inc I’ve always believed that a good programmer finds the information they need when they need it Nothing could be more true to that statement than with this book I am new to Grails development and was looking for a good book/reference guide I found it in Grails: A QuickStart Guide Even after reading it, I found myself referring to it often to help me along It was not written at a level that assumes the reader is an expert Java developer or familiar with the popular frameworks I found it easy to understand, and the code examples were excellent in displaying the ease with which a relative newcomer can become a Groovy developer using Grails I highly recommend this book for anyone who is just starting to develop Grails applications Doug Burns Programmer/analyst I’ve read several books on the Grails framework, and this is the first that explained things enough that I felt confident building something from scratch If you know Ruby on Rails, you should definitely look at this framework, and this book really helps you get your feet wet Brian Hogan Rails consultant and trainer Great book! Dave does a fantastic job of presenting the framework in an easy-to-follow and very accessible way Excellent! Jeff Brown Core Grails developer Grails A Quick-Start Guide Dave Klein The Pragmatic Bookshelf Raleigh, North Carolina Dallas, Texas Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g device are trademarks of The Pragmatic Programmers, LLC Every precaution was taken in the preparation of this book However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun For more information, as well as the latest Pragmatic titles, please visit us at http://www.pragprog.com Copyright © 2009 Pragmatic Programmers, LLC All rights reserved No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior consent of the publisher Printed in the United States of America ISBN-10: 1-934356-46-8 ISBN-13: 978-1-934356-46-3 Printed on acid-free paper P1.0 printing, October 2009 Version: 2009-10-19 Contents Introduction 1.1 Let Me Tell You About Grails 1.2 How Does Grails Do It? 1.3 Why This Book? 1.4 Who Should Read This Book 1.5 Source Code 1.6 Enough Groovy to Be Dangerous 1.7 Groovy Syntax Compared to Java 1.8 Groovy Strings 1.9 Groovy Closures 1.10 Groovy Collections 1.11 Where to from Here? 1.12 Acknowledgments Our Project 2.1 Introducing TekDays.com 2.2 Meet Our Customer 2.3 Iteration Zero 2.4 Summary Laying the Foundation 3.1 Creating a Domain Class 3.2 More About Domain Classes 3.3 Testing Our Domain Class 3.4 Taking Control of Our Domain 3.5 Modifying Code That Doesn’t Exist 3.6 Bootstrapping Some Test Data 3.7 Summary 10 10 11 12 13 13 14 14 16 17 18 22 23 25 26 26 28 34 35 35 37 38 41 42 45 49 CONTENTS Building Relationships 4.1 The TekUser Domain Class 4.2 One-to-One Relationships 4.3 One-to-Many Relationships 4.4 Collections of Simple Data Types 4.5 Adding a Sponsor Class 4.6 Many-to-Many Relationships 4.7 Finishing Up the Domain Model 4.8 Summary 53 53 55 60 62 64 66 71 73 Beyond Scaffolding 5.1 Generating Scaffolding Code 5.2 Anatomy of a Grails Controller 5.3 Grails Views with Groovy Server Pages 5.4 Configuring a Database 5.5 Summary 75 75 76 83 94 97 Getting Things Done 6.1 Changing All Our Views at Once 6.2 Modifying the Scaffolded Views 6.3 Event Task List 6.4 Grails Service Classes 6.5 Integration Testing 6.6 Modifying the Task Class 6.7 Summary 98 98 99 106 108 111 113 114 Forum Messages and UI Tricks 7.1 Restricting Messages to an Event 7.2 Of Templates and Ajax 7.3 Display Message Threads with a Custom Tag 7.4 Summary 116 116 122 128 133 Knock, Knock: Who’s There? Grails 8.1 Grails Security Options 8.2 Logging In 8.3 Filters 8.4 Logging Out 8.5 Summary 135 135 136 139 142 144 Security CONTENTS Big-Picture Views 9.1 Home Page Makeover 9.2 Creating a New Controller 9.3 Designing the Dashboard View 9.4 Adding the Dashboard Action 9.5 Adding a Menu 9.6 Linking to the Dashboard 9.7 Summary 10 Seek, 10.1 10.2 10.3 10.4 and You Shall Find Search Using Dynamic Finders Hibernate Criteria Builder The Big Guns: The Searchable Plug-In Summary 11 Icing 11.1 11.2 11.3 on the Cake The Grails UI Plug-In The Twitter Plug-In Making the Event Page Customizable Plug-In 11.4 User-Friendly URLs 11.5 Summary 12 Deployment and Beyond 12.1 Using a JNDI Data Source 12.2 Creating and Deploying a WAR 12.3 Next Steps 12.4 Parting Thoughts 146 146 149 150 156 158 160 162 163 163 166 170 177 with the 178 178 183 Blurb 189 193 196 198 198 200 201 202 A Additional CSS Rules 203 B Resources B.1 Online Resources B.2 Meet the G3 Community B.3 Other Resources B.4 IDE Support 205 205 206 210 211 C Bibliography 213 Index 214 Chapter Introduction 1.1 Let Me Tell You About Grails Web development is a very rewarding experience Building an application that can run from anywhere in the world is pretty awesome Even in a corporate environment, you can deliver new features to your users, no matter where they are located, without ever touching their computer It’s a beautiful thing Consider also what you can build: the potential for creativity on the Web is unlimited The Java platform brings even more power to the party The Java Servlet API and the plethora of libraries and frameworks in the Java ecosystem make it possible to include almost any feature you could want in a web application It is an exciting time to be a web developer However, it’s not all sweetness and light With all this power comes a level of complexity that can be daunting With most Java-based web frameworks, there are multiple XML configuration files to deal with, along with classes to extend and interfaces to implement As a project grows, this complexity seems to increase exponentially Many web application frameworks have been created to address this problem So many Java web frameworks have been developed that you might ask, “Why Grails? Why another framework?” That was my thought when I first heard about Grails I was at a conference that featured sessions on an array of Java-related technologies and was planning to attend several talks on JavaServer Faces (JSF), which is what I was working with at the time During one of the time slots where there was nothing JSF-related, I wandered into < G : SELECT > G IT Git Brown, Jeff, 201 tag, 125 tag, 84 tag, 84 tag, 84 tag, 85, 87, 94, 100, 118, 119, 124, 153, 154, 160 tag, 143 tag, 164, 169 GORM (Grails Object Relational Mapping) dynamic finders, 57 synthesizing behavior at runtime, 57 tag, 86 Grails mail plug-in, 201 Grails UI plug-in, 178–183 adding a confirmation dialog box, 180 components attribute, 181 grails install-plugin grails-ui script, 181 tag, 181 tag, 181 installing, 181 triggers, 182 using a YUI CSS class, 183 Yahoo! User Interface (YUI) components, 181 see also Plug-ins (Grails) grails-app directory, 32 grails command, 30 grails create-controller command, 54 grails create-service Task script, 109 grails create-tag-lib script, 129 grails generate-all script, 75 grails help command, 30 grails install-plugin grails-ui script, 181 grails install-plugin script, 171 grails install-searchable-config script, 172 grails list-plugins script, 171 grails test-app script, 58, 113 grails war script, 201 tag, 125, 132 list of attributes, 126 messageInstance, 126 update attribute, 126 tag, 90 tag, 122, 151, 190 tag, 160 Groovy $, 17 TAG ==, in assert statements, 16

Ngày đăng: 18/02/2014, 05:20

TỪ KHÓA LIÊN QUAN

w