|This is work in progress|
- Some Groovy basics
- Getting started with Grails
- Useful links
- How do I create an application I can toy around with?
- Removing the ~/.grails directory can sometimes solve strange errors
- How do you upgrade a Grails project to a new version of the Grails framework?
- Using Maven with Grails
- Domain classes
- Which standard methods should you implement in a domain class?
- How do you group domain classes in packages?
- How do you handle non-persistent domain classes in Grails?
Groovy adds utility methods to a lot of common classes. You'll find the details referred to as the GDK - and its available on http://groovy.codehaus.org/groovy-jdk/
This gives the content of the web page http://www.vg.no. Resolution is as follows.
The string is a groovy.lang.GString. This class does not have a toURL() method.
However, it has got an invokeMethod. This method does a toString, and then tries to call the method (in this case , toURL()) on the object returned from toString.
toString returns a java.lang.String. This class does not have a toURL() method. However, there are methods added by grooovy to make stuff better. These methods can be found on the GDK link above. For java.lang.String, a getURL is added which returns a java.net.URL. getText is then called on this object.
- Grails homepage
- Mastering Grails tutorials by Scott Davis
Do the following:
See below for how to use Maven for building your Grails project.
Try it if you don't understand why you get a strange error.
- download the new grails version
- upgrade your grails project like this:
Use the Maven plugin for Grails.
Create a Maven pom for your project like this:
Note: You might need to add a log4j dependency in your pom.xml to get your project to compile.
Add the mysql dependency to the POM:
Then, update grails-app/conf/DataSource.groovy:
There is an underlying assumption here: All developers and test instances will run mysql without a root password. This might not be a good idea if tests use live data.
It is also not a good idea to let the application update the schema in production use, so switch that off.
Next, start mysql and create your database
I have not set the locale or character set for the database here. You should.
Next, package and run the application:
It is a good idea to implement String toString() for instance like this:
This is particularly important if you are using scaffolding - otherwise the views for the scaffolded pages will use "ID: Type" in relationships (drop-down selects and cross-reference links).
They are basically used for the same things that a spring service bean, or an EJB session bean are used for, i.e. providing re-usable services for the front-end part of an application, handling transactions, and handling integration with external services. The following illustration gives one example of how they can be used in a Grails + Java context!grails_and_spring2.png!
(Figure from http://www.grails-exchange.com/files/DaveSyer%20-%20Grails&Spring.pdf)
Use the grails create-service method.