Leanpub Header

Skip to main content

Grails Goodness Notebook

Experience the Grails platform through code snippets

Learn more about (hidden) Grails features with code snippets and short articles. The articles and code will get you started quickly and will give more insight in Grails.

The author is letting you choose the price you pay for this book!

Pick Your Price...
PDF
EPUB
WEB
243
Pages
About

About

About the Book

In 2009 I started to write about features in Grails I didn't want to forget at my blog Messages from mrhaki. The posts are relatively short and filled with code samples.

The Grails Goodness Notebook contains the blog posts about Grails. The posts are bundled and categorized into sections. Each section starts with the simpler features and ends with more advanced Grails features. The book is intended to browse through the subjects. You should be able to just open the book at a random page and learn more about Grails. Maybe pick it up once in a while and learn a bit more about known and lesser known features of Grails.

The book is updated on February 1st 2016 with the following new posts:

  • Run Grails Application As Docker Container
  • Enable Hot Reloading For Non-Development Environments
  • Change Locale With Request Parameter
  • Go To Related Classes In IntelliJ IDEA
  • Quickly Create GSP From Controller In IntelliJ IDEA
  • Using Spring Cloud Config Server
  • Changing Gradle Version
  • Getting More Information About A Profile
  • Using Features When Creating An Application

The book categorizes the posts in the following sections:

  • Configuration
  • The Command LIne
  • Grails Object Relational Mapping (GORM)
  • Validation
  • Controllers
  • Groovy Server Pages (GSP)
  • REST
  • The Service Layer
  • Grails and Spring
  • Internationalization (i18n)
  • IDE
  • Miscellaneous

Share this book

Categories

Price

Pick Your Price...

Minimum price

Free!

$7.99

You pay

$0.00

Author earns

$0.00
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 0)

0
The author will earn $0.00 from your purchase!
You can get credits monthly with a Reader Membership

Author

About the Author

Hubert A. Klein Ikkink (mrhaki)

Hello. I am a passionate Groovy and Java developer based in Tilburg, The Netherlands. My goal is to write software, like Pixar makes movies, BMW makes cars, Bang & Olufsen makes audio and TV systems and Apple makes computers and devices: clean, elegant, user-centered and high quality.

Contents

Table of Contents

About Me

Introduction

  1. Grails versions
  2. Code samples

Configuration

  1. Using Bintray JCenter as Repository
  2. Add Banner to Grails Application
  3. Add Banner To Grails 3.1 Application
  4. Set Log Level for Grails Artifacts
  5. Add Some Color to Our Logging
  6. Save Application PID in File
  7. Saving Server Port In A File
  8. Log Startup Info
  9. Changing Gradle Version
  10. Adding Health Check Indicators
  11. Add Git Commit Information To Info Endpoint
  12. Adding Custom Info To Info Endpoint
  13. Passing System Properties With Gradle
  14. Update Application With Newer Grails Version
  15. Access Grails Application in BootStrap
  16. Using Spring Cloud Config Server
  17. Multiple BootStraps
  18. Cleaning Up Before WAR Creation
  19. Logging Service Method Calls with Dynamic Groovy
  20. Multiple Environments
  21. Execute Code for Current Environment
  22. Use Different External Configuration Files
  23. Using External Configuration Files Per Environment
  24. Change Base Name For External Configuration Files
  25. Using Random Values For Configuration Properties
  26. Pass Configuration Values Via Environment Variables
  27. Pass JSON Configuration Via Command Line
  28. One WAR to Rule Them All
  29. Customize the URL Format
  30. Add Additional Web Application to Tomcat
  31. Use a Different jQuery UI Theme with Resources Plugin
  32. Use A Different Logging Configuration File
  33. Add a DailyRollingFileAppender to Grails Logging
  34. Use Log4j Extras Companion RollingFileAppender
  35. Use TimeAndSizeRollingAppender for Logging
  36. Change Context Path of a Grails Application for Jetty
  37. Change Version For Dependency Defined By BOM

The Command Line

  1. Script Name Abbreviation
  2. Shortcut to Open Test Reports in Interactive Console
  3. Run Gradle Tasks In Grails Interactive Mode
  4. See Information About Plugins
  5. Get List Of Application Profiles
  6. Getting More Information About A Profile
  7. Using Features When Creating An Application
  8. Create Report of URL Mappings
  9. Compiling GSP from the Command-Line
  10. Profile Script Tasks
  11. No More Questions
  12. Create New Application without Wrapper
  13. Enable Hot Reloading For Non-Development Environments
  14. Generate ANT Build Script
  15. Generate Default .gitignore Or .hgignore File
  16. Extending IntegrateWith Command
  17. Using Wrapper for Running Grails Commands Without Grails Installation
  18. Cleaning Up
  19. Using Aliases as Command Shortcuts
  20. Run Groovy Scripts in Grails Context
  21. Add More Paths to the Stats Report
  22. Access Configuration in Grails Scripts
  23. Simple Script to Create WAR Files for Each Environment

Grails Object Relational Mapping (GORM)

  1. Getting First or Last Instance of Domain Classes
  2. Using Hibernate Native SQL Queries
  3. Using Groovy SQL
  4. Refactoring Criteria Contents

Validation and Data Binding

  1. Add Extra Valid Domains and Authorities for URL Validation
  2. Combining Constraints with Shared Constraints
  3. Custom Data Binding with @DataBinding Annotation

Controllers

  1. Type Conversion on Parameters
  2. Get Values from Parameters with Same Name
  3. Get Request Parameters with Default Values
  4. Date Request Parameter Value Conversions
  5. Binding Method Arguments in Controller Methods
  6. Controller Properties as Model
  7. Using the header Method to Set Response Headers
  8. Render Binary Output with the File Attribute
  9. Exception Methods in Controllers
  10. Namespace Support for Controllers
  11. Grouping URL Mappings

Groovy Server Pages (GSP)

  1. Change Scaffolding Templates in Grails
  2. Use the GSP Template Engine in a Controller
  3. The Template Namespace
  4. Templates Can Have a Body
  5. The Link Namespace
  6. Format Boolean Values with the formatBoolean Tag
  7. Encode Content with the encodeAs Tag
  8. Set Application Wide Default Layout
  9. Applying Layouts in Layouts
  10. Applying Layouts in Layouts Revisited
  11. Access Action and Controller Name in GSP
  12. Get GrailsApplication and ApplicationContext in GSP
  13. Use Services in GSP with g:set Tag
  14. Generating Raw Output with Raw Codec
  15. Using Closures for Select Value Rendering

REST

  1. Customize Resource Mappings
  2. Pretty Print XML and JSON Output
  3. Include Domain Version Property in JSON and XML Output
  4. Enable Accept Header for User Agent Requests
  5. Custom Controller Class with Resource Annotation
  6. Change Response Formats in RestfulController
  7. Register Custom Marshaller Using ObjectMarshallerRegisterer
  8. Using Converter Named Configurations with Default Renderers
  9. Rendering Partial RESTful Responses
  10. Customize Root Element Name Collections for XML Marshalling

The Service Layer

  1. Generate Links Outside Controllers or Tag Libraries
  2. Render GSP Views And Templates Outside Controllers
  3. Accessing Resources with Resource and ResourceLocator

Grails and Spring

  1. Injecting Grails Services into Spring Beans
  2. Conditionally Load Bean Definitions from resources.groovy
  3. Using Spring Bean Aliases
  4. Use Constructor Argument Based Dependency Injection
  5. Set Property Values of Spring Beans in resources.groovy
  6. Setting Property Values through Configuration
  7. Defining Spring Beans With doWithSpring Method
  8. Use Spring Java Configuration
  9. Conditionally Load Beans in Java Configuration Based on Grails Environment
  10. Don’t Invalidate Session After Logout with Spring Security Plugin

Testing

  1. See Test Output on the Command Line
  2. Invoking a Single Test Method
  3. Cleaning Before Running Tests
  4. Rerun the Latest Failed Test
  5. Running Tests Continuously
  6. Testing for Chain Result in Controller
  7. Checking Results from Forward Action in Controller Unit Tests
  8. Using Codecs in Test Classes
  9. Unit Testing Render Templates from Controller
  10. Testing Views and Templates
  11. Passing Objects to Attributes of Tags in Unit Tests
  12. Set Request Locale in Unit Tests
  13. Using MetaClass with Testing
  14. Mocking the Configuration in Unit Tests
  15. Use Random Server Port In Integration Tests

Internationalization (i18n)

  1. Define Date Format in i18n ResourceBundle
  2. Splitting i18n Message Bundles
  3. Change Locale With Request Parameter
  4. Internationalize Javascript Messages with JAWR Plugin

IDE

  1. Quickly Create GSP From Controller In IntelliJ IDEA
  2. Go To Related Classes In IntelliJ IDEA
  3. Debugging App in Forked Mode
  4. Run Forked Tests in IntelliJ IDEA

Miscellaneous

  1. Creating A Runnable Distribution
  2. Creating A Fully Executable Jar
  3. Run Grails Application As Docker Container

Converted Files

  1. 20161019-grails-goodness-skip-bootstrap-code
  2. 20161118-grails-goodness-notebook-is-updated
  3. 20161123-gails-goodness-enabling-grails-view-in
  4. 20161209-grails-goodness-writing-log-messages
  5. 20170221-grails-goodness-using-domain-classes
  6. 20170227-grails-goodness-custom-json-and-markup

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub