【文件属性】:
文件名称:Grails A Quick-Start Guide:Dave Klein (DK)
文件大小:5.55MB
文件格式:PDF
更新时间:2013-11-04 10:21:46
Grails
http://www.infoq.com/cn/articles/klein-grailsquickstartguide
1 Introduction 10
1.1 Let Me Tell You About Grails. . . . . . . . . . . . . . . . 10
1.2 How Does Grails Do It? . . . . . . . . . . . . . . . . . . . 11
1.3 Why This Book? . . . . . . . . . . . . . . . . . . . . . . . 12
1.4 Who Should Read This Book . . . . . . . . . . . . . . . 13
1.5 Source Code . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.6 Enough Groovy to Be Dangerous . . . . . . . . . . . . . 14
1.7 Groovy Syntax Compared to Java . . . . . . . . . . . . 14
1.8 Groovy Strings . . . . . . . . . . . . . . . . . . . . . . . . 16
1.9 Groovy Closures . . . . . . . . . . . . . . . . . . . . . . . 17
1.10 Groovy Collections . . . . . . . . . . . . . . . . . . . . . 18
1.11 Where to from Here? . . . . . . . . . . . . . . . . . . . . 22
1.12 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . 23
2 Our Project 25
2.1 Introducing TekDays.com . . . . . . . . . . . . . . . . . 26
2.2 Meet Our Customer . . . . . . . . . . . . . . . . . . . . . 26
2.3 Iteration Zero . . . . . . . . . . . . . . . . . . . . . . . . 28
2.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3 Laying the Foundation 35
3.1 Creating a Domain Class . . . . . . . . . . . . . . . . . . 35
3.2 More About Domain Classes . . . . . . . . . . . . . . . 37
3.3 Testing Our Domain Class . . . . . . . . . . . . . . . . . 38
3.4 Taking Control of Our Domain . . . . . . . . . . . . . . 41
3.5 Modifying Code That Doesn’t Exist . . . . . . . . . . . . 42
3.6 Bootstrapping Some Test Data . . . . . . . . . . . . . . 45
3.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4 Building Relationships 53
4.1 The TekUser Domain Class . . . . . . . . . . . . . . . . 53
4.2 One-to-One Relationships . . . . . . . . . . . . . . . . . 55
4.3 One-to-Many Relationships . . . . . . . . . . . . . . . . 60
4.4 Collections of Simple Data Types . . . . . . . . . . . . . 62
4.5 Adding a Sponsor Class . . . . . . . . . . . . . . . . . . 64
4.6 Many-to-Many Relationships . . . . . . . . . . . . . . . 66
4.7 Finishing Up the Domain Model . . . . . . . . . . . . . 71
4.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
5 Beyond Scaffolding 75
5.1 Generating Scaffolding Code . . . . . . . . . . . . . . . 75
5.2 Anatomy of a Grails Controller . . . . . . . . . . . . . . 76
5.3 Grails Views with Groovy Server Pages . . . . . . . . . . 83
5.4 Configuring a Database . . . . . . . . . . . . . . . . . . 94
5.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
6 Getting Things Done 98
6.1 Changing All Our Views at Once . . . . . . . . . . . . . 98
6.2 Modifying the Scaffolded Views . . . . . . . . . . . . . . 99
6.3 Event Task List . . . . . . . . . . . . . . . . . . . . . . . 106
6.4 Grails Service Classes . . . . . . . . . . . . . . . . . . . 108
6.5 Integration Testing . . . . . . . . . . . . . . . . . . . . . 111
6.6 Modifying the Task Class . . . . . . . . . . . . . . . . . 113
6.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
7 Forum Messages and UI Tricks 116
7.1 Restricting Messages to an Event . . . . . . . . . . . . . 116
7.2 Of Templates and Ajax . . . . . . . . . . . . . . . . . . . 122
7.3 Display Message Threads with a Custom Tag . . . . . . 128
7.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
8 Knock, Knock: Who’s There? Grails Security 135
8.1 Grails Security Options . . . . . . . . . . . . . . . . . . 135
8.2 Logging In . . . . . . . . . . . . . . . . . . . . . . . . . . 136
8.3 Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
8.4 Logging Out . . . . . . . . . . . . . . . . . . . . . . . . . 142
8.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
9 Big-Picture Views 146
9.1 Home Page Makeover . . . . . . . . . . . . . . . . . . . . 146
9.2 Creating a New Controller . . . . . . . . . . . . . . . . . 149
9.3 Designing the Dashboard View . . . . . . . . . . . . . . 150
9.4 Adding the Dashboard Action . . . . . . . . . . . . . . . 156
9.5 Adding a Menu . . . . . . . . . . . . . . . . . . . . . . . 158
9.6 Linking to the Dashboard . . . . . . . . . . . . . . . . . 160
9.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
10 Seek, and You Shall Find 163
10.1 Search Using Dynamic Finders . . . . . . . . . . . . . . 163
10.2 Hibernate Criteria Builder . . . . . . . . . . . . . . . . . 166
10.3 The Big Guns: The Searchable Plug-In . . . . . . . . . . 170
10.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
11 Icing on the Cake 178
11.1 The Grails UI Plug-In . . . . . . . . . . . . . . . . . . . . 178
11.2 The Twitter Plug-In . . . . . . . . . . . . . . . . . . . . . 183
11.3 Making the Event Page Customizable with the Blurb
Plug-In . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
11.4 User-Friendly URLs . . . . . . . . . . . . . . . . . . . . . 193
11.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
12 Deployment and Beyond 198
12.1 Using a JNDI Data Source . . . . . . . . . . . . . . . . . 198
12.2 Creating and Deploying a WAR . . . . . . . . . . . . . . 200
12.3 Next Steps . . . . . . . . . . . . . . . . . . . . . . . . . . 201
12.4 Parting Thoughts . . . . . . . . . . . . . . . . . . . . . . 202
A Additional CSS Rules 203
B Resources 205
B.1 Online Resources . . . . . . . . . . . . . . . . . . . . . . 205
B.2 Meet the G3 Community . . . . . . . . . . . . . . . . . . 206
B.3 Other Resources . . . . . . . . . . . . . . . . . . . . . . 210
B.4 IDE Support . . . . . . . . . . . . . . . . . . . . . . . . . 211
C Bibliography 213
Index 214
网友评论
- 不错,很有用,谢谢楼主!