Java Reference
In-Depth Information
Services are injected by name (the term is
autowiring
in Spring) into the controller, so de-
claring a variable of the same name as the service using a lowercase first letter tells Grails
to provide an instance of the service at that point. The service is used inside the
save
method to update the
Castle
before saving it.
Grails Services
Use Grails applications with the standard, layered architecture. Let controllers delegate to
services, and let the transactional services work with the databases.
As noted earlier in this section, Grails has a rich set of available plugins. One that's useful
in this application is the Google Visualization plugin, which provides a custom library of
GSP tags that generate JavaScript for Google Maps applications.
As with everything else, Grails manages plugin installations in a standard way. The file
BuildConfig.groovy
in the grails-app/conf folder has a section on plugins. Adding
the proper statement to that file causes Grails to automatically download and install the
plugin on its next application start.
Here's the relevant section of the
BuildConfig.groovy
file:
plugins {
runtime ":hibernate:$grailsVersion"
runtime ":jquery:1.8.3"
runtime ":resources:1.1.6"
compile ":google-visualization:0.6.2"
build ":tomcat:$grailsVersion"
}
The documentation for the Google Visualization plugin says that to use it, add the tag
<gvisualization:apiImport />
to the
<head>
section of the GSP where you
want the map to appear. Then the plugin provides a
<gvisualization:map />
tag to
produce the map itself. The
map
tag uses
columns
and
data
attributes for the informa-
tion for the map points, which I need to specify.