Matt Greencroft has his say

Matt's Blog

Groovy Course Correction - Chapter 21 (Files and Templates)

10-Sep-2014 in Errata Groovy

I've been made aware today (thanks to a customer asking us to help solve a problem with his code relating to chapter 21 of the Groovy course) of a mistake on the video and with the file supplied for this chapter.

In the exercise I set you to practice with templates, I show on screen the file called DailyCheckInTemplate.txt from the practicals and code folder. This is at approximately 15:22 on the video.

The video tells you to copy the file from the templates folder in chapter 17, and shows you the file on screen. Unfortunately the file provided and shown is not right - it includes fields like $it.date - these should be $date.

The problem with using $it.date is that Groovy will be looking for a key of it.date in the map of properties we supply to the template engine, but the keys won't be preceeded with the "it" - that is we'll be creating a map with a key of "date" and not "it.date".

If you use the version of the template supplied in the starting workspace, you'll get an error message similar to this:

Caught: groovy.lang.MissingPropertyException: No such property: it for class: SimpleTemplateScript1
groovy.lang.MissingPropertyException: No such property: it for class: SimpleTemplateScript1
at SimpleTemplateScript1.run(SimpleTemplateScript1.groovy:1)

The version of this file in the final workspace for chapter 21 is correct, so please pick up the DailyCheckinTemplate.txt file from the following location instead, and you'll not have any problems with your code:

PracticalsAndCode / End of Chapter Workspaces / Chapter 21 - Files and Templates / Hotel Manager / templates / DailyCheckInTemplate.txt

Listen via:


About Matt

I'm a Java developer and trainer for Virtual Pair Programmers, where I present video based training courses on Java, Spring and associated frameworks. I'm currently working on a few different web projects.


Be notified of new posts