Groovy and Grails Recipes is the busy developer's guide to developing applications in Groovy and Grails. Rather than boring you with theoretical knowledge of "yet another language/framework," this book delves straight into solving real-life problems in Groovy and Grails using easy-to-understand, well-explained code snippets. Through learning by example, you will be able to pick up on Groovy and Grails quickly and use the book as an essential reference when developing applications.
Table of contents
- Title Page
- Contents at a Glance
- About the Author
- About the Technical Reviewer
PART 1: Groovy by Example
CHAPTER 1: Getting Started with Groovy
- 1-1. What Is Groovy?
- 1-2. What Is Wrong with Java?
- 1-3. How Does Groovy Address the Shortcomings of Java?
- 1-4. How Do I Download and Install Groovy?
- 1-5. What Tools Come with Groovy?
- 1-6. How Do I Use the Groovy Shell?
- 1-7. How Do I Use the Groovy Console?
- 1-8. How Do I Use groovyc and groovy?
- 1-9. Is There IDE Support for Groovy?
- 1-10. How Do I Integrate Groovy with Eclipse?
- 1-11. How Do I Integrate Groovy with IntelliJ IDEA?
- CHAPTER 2: From Java to Groovy
CHAPTER 3: Groovy Data Types and Control Structures
- 3-1. What Are the Different Kinds of Strings in Groovy and How Do I Use Them?
- 3-2. How Do I Use Regular Expressions in Groovy?
- 3-3. How Are Numbers in Groovy Different from Those in Java?
- 3-4. How Do I Use Lists in Groovy?
- 3-5. How Do I Implement a Merge Sort in Groovy?
- 3-6. How Do I Use Maps in Groovy?
- 3-7. What Are Ranges and How Do I Use Them in Groovy?
- 3-8. What Is the Groovy Truth?
- 3-9. How Is the switch Statement in Groovy Different from Java?
- 3-10. How Do I Perform Looping in Groovy?
CHAPTER 4: Object-Oriented Groovy
- 4-1. What Are the Differences Between Classes and Scripts?
- 4-2. How Do I Use Packages?
- 4-3. What Is Type Aliasing and How Do I Use It?
- 4-4. How Do I Use Inheritance in Groovy?
- 4-5. How Do I Use Interfaces in Groovy?
- 4-6. What Are Multimethods and How Do I Use Them?
- 4-7. What Are Categories and How Do I Use Them?
- 4-8. How Are Groovy Fields and Local Variables Different from Those in Java?
- 4-9. How Are Groovy Methods Different from Java Methods?
- 4-10. How Are Groovy Constructors Different from Those in Java?
- 4-11. What Are GroovyBeans?
- 4-12. What Are GPaths?
- 4-13. How Do I Use the Expando Class?
- 4-14. What Is Metaclass and How Do I Use It?
- 4-15. How Do I Intercept All Method Calls on an Object?
- 4-16. How Do I Intercept Methods That Don't Exist on a Class?
- 4-17. How Do I Add Additional Behavior to a Class by Using ExpandoMetaClass?
CHAPTER 5: Closures
- 5-1. What Is a Closure?
- 5-2. Why Do I Need Closures?
- 5-3. How Do Closures Compare with Anonymous Inner Classes?
- 5-4. How Do I Create a Closure?
- 5-5. How Do I Call a Closure?
- 5-6. How Do I Return a Value from a Closure?
- 5-7. How Do I Reuse a Method as a Closure?
- 5-8. How Do I Pass a Closure as an Argument to Another Method?
- 5-9. What Is the Scope of a Closure?
- 5-10. What Do this, owner, and delegate Mean Inside a Closure?
- 5-11. How Can I Return from a Closure?
- 5-12. What Does It Mean to Curry Closures?
- 5-13. How Do I Use a Closure Inside a switch Statement?
- 5-14. How Do I Get More Information About the Parameters Passed to a Closure?
- 5-15. How Do I Use Closures Inside a Map?
- 5-16. How Do I Use Closures with Files?
CHAPTER 6: Builders
- 6-1. What Are Builders?
- 6-2. Why Do I Need Builders?
- 6-3. How Do I Use MarkupBuilder to Build XML?
- 6-4. How Do I Use MarkupBuilder to Build HTML?
- 6-5. How Do I Use NodeBuilder to Build a Tree of Objects?
- 6-6. How Do I Use ObjectGraphBuilder to Build a Tree of Objects?
- 6-7. How Do I Use AntBuilder to Write Ant Tasks?
- 6-8. How Do I Use SwingBuilder to Create Swing Widgets?
- 6-9. How Do I Use Layout Managers with SwingBuilder?
- 6-10. How Do I Add an Action to a Swing Widget?
- 6-11. How Do I Share Actions Among Widgets?
- 6-12. How Do I Use Swing Models?
- 6-13. How Do I Create My Own Builder?
CHAPTER 7: Working with Databases
- 7-1. How Do I Connect to a Database?
- 7-2. How Do I Use Connection Pooling?
- 7-3. How Do I Create a New Table?
- 7-4. How Do I Insert, Update, and Delete Data?
- 7-5. How Do I Read Data from My Tables?
- 7-6. How Do I Retrieve a Table's Metadata?
- 7-7. How Do I Use DataSet?
- 7-8. How Do I Use DataSet with Joined Tables?
CHAPTER 8: Testing with Groovy
- 8-1. How Do I Write an Inline Test in Groovy?
- 8-2. How Do I Write a Test Class in Groovy?
- 8-3. How Do I Use Groovy to Test Java Code?
- 8-4. How Do I Organize Tests into Suites and Run Them from My IDE?
- 8-5. How Do I Use Ant to Run My Tests?
- 8-6. How Do I Use Maven to Run My Tests?
- 8-7. What Are the Advanced Testing Techniques Offered by Groovy?
- 8-8. How Do I Use Maps to Test My Code?
- 8-9. How Do I Use an Expando Object to Test My Code?
- 8-10. How Do I Use Stubs and Mocks in Groovy?
- 8-11. How Do I Use GroovyLogTestCase?
- 8-12. How Can I Measure My Code Coverage by Using Cobertura?
CHAPTER 9: Miscellaneous Recipes
- 9-1. How Do I Use Groovy Templates to Generate Dynamic and Reusable Content?
- 9-2. How Do I Use Groovlets to Generate Dynamic Web Content?
- 9-3. How Do I Read and Process XML with XmlParser?
- 9-4. How Do I Read and Process XML with XmlSlurper?
- 9-5. How Do I Use XPath?
- 9-6. How Do I Read an XML RSS Feed?
- 9-7. How Do I Use Groovy on the Command Line?
- 9-8. How Do I Use ConfigSlurper to Write Configuration Files?
- 9-9. How Do I Use Groovy to Run External Processes?
- 9-10. How Do I Download a File in Groovy?
- 9-11. How Do I Process All Files in a Directory?
- 9-12. How Do I Count All Occurrences of a Word in a String?
- CHAPTER 1: Getting Started with Groovy
PART 2: Grails by Example
- CHAPTER 10: Getting Started with Grails
CHAPTER 11: The Web Layer
- 11-1. How Do I Create a Controller?
- 11-2. What Are Groovy Server Pages?
- 11-3. What Is the Relationship Between Controllers and GSPs?
- 11-4. How Can I Pass Variables from a Controller to a GSP?
- 11-5. How Do I Use Tags as Method Calls?
- 11-6. How Can I Have Multiple Actions Inside a Controller?
- 11-7. What Are the Available Implicit Objects Inside a Controller and a GSP?
- 11-8. How Can I Render a Different View for the User?
- 11-9. How Do I Chain Actions?
- 11-10. How Do I Intercept Actions in a Controller?
- 11-11. How Do I Bind Incoming Parameters?
- 11-12. How Do I Output JSON?
- 11-13. How Do I Render Domain Classes as XML or JSON (Marshalling)?
- 11-14. How Do I Upload and Download Files?
- 11-15. What Are Templates and How Do I Use Them?
- 11-16. How Do I Change the Application's Layout and Look?
- 11-17. How Do I Write My Own Custom Tags?
- 11-18. How Do I Use Filters?
- 11-19. How Do I Use Ajax?
CHAPTER 12: The Data Layer
- 12-1. How Do I Configure My Application to Use a Database?
- 12-2. How Do I Create a Domain Class?
- 12-3. How Do I Model Relationships?
- 12-4. How Do I Use Composition?
- 12-5. How Do I Perform CRUD Operations on My Domain Classes?
- 12-6. How Do I Query with GORM?
- 12-7. How Do I Use Dynamic Finders?
- 12-8. How Do I Use Criteria?
- 12-9. How Do I Use HQL?
- 12-10. How Do I Use Inheritance?
- 12-11. What is Optimistic and Pessimistic Locking?
- 12-12. How Do I Use Events?
- 12-13. How Do I Use Timestamps?
- 12-14. How Do I Use Caching?
- 12-15. How Do I Use a Custom Database Identifier?
- 12-16. How Do I Use a Composite Primary Key?
- 12-17. How Do I Add an Index to a Column?
CHAPTER 13: Scaffolding
- 13-1. How Do I Use Dynamic Scaffolding?
- 13-2. How Do I Dynamically Scaffold Relationships?
- 13-3. How Do I Customize the Generated Views?
- 13-4. What Are the Built-in Constraints in Grails?
- 13-5. How Do I Override Scaffolded Actions and Views?
- 13-6. How Do I Use Static Scaffolding?
- 13-7. How Do I Change the Scaffolding Templates?
- 13-8. How Do I Add My Own Property Editor?
- 13-9. How Do I Use Scaffolding with Hibernate Mapped Classes?
CHAPTER 14: Security
- 14-1. How Do I Protect My Application from SQL Injection Attacks?
- 14-2. How Do I Protect My Application from Cross-Site Scripting (XSS)?
- 14-3. How Do I Use Codecs?
- 14-4. How Do I Restrict the HTTP Request Methods That Can Call an Action?
- 14-5. How Do I Implement Authentication in My Application?
- 14-6. How Do I Use the AcegiSecurity Plug-In?
- 14-7. How Do I Use OpenID?
- CHAPTER 15: Testing
CHAPTER 16: Miscellaneous Recipes
- 16-1. What About the Service Layer?
- 16-2. How Can I Use Some of Spring's Advanced Features with Grails?
- 16-3. How Do I Configure My Application by Using External Files?
- 16-4. How Do I Configure Logging in My Application?
- 16-5. How Do I Use Grails with Maven 2?
- 16-6. How Do I Use Grails with REST?
- 16-7. How Do I Write SOAP Web Services in Grails with CXF?
- Title: Groovy and Grails Recipes
- Release date: December 2008
- Publisher(s): Apress
- ISBN: 9781430216001
You might also like
Understanding the Grails 3 Domain Model
In this video course, expert Java trainer and consultant Ken Kousen shows you how to model …
Java Coding Problems
Develop your coding skills by exploring Java concepts and techniques such as Strings, Objects and Types, …
Grails in Action, Second Edition
Grails in Action, Second Edition is a comprehensive introduction to Grails 2. In this totally revised …
Groovy in Action, Second Edition
Summary Groovy in Action, Second Edition About the Technology In the last ten years, Groovy has …