Learn Java for Web Development

(Tina Meador) #1
CHAPTER 7: Rapid Web Development with Grails 323

Enter the name of the domain class in the name field and click Finish. Grails creates the Book domain
class and BookTests, as shown in the following output:


Loading Grails 2.2.4
| Environment set to development.....
| Created file grails-app/domain/bookstore/Book.groovy
| Compiling 1 source files.....
| Created file test/unit/bookstore/BookTests.groovy


Listing 7-8 illustrates the Book class generated by Grails.


Listing 7-8. Book Domain Class Generated by Grails


package bookstore


class Book {


static constraints = {
}
}


The Book class in Listing 7-8 is empty. Now you can complete this domain class as illustrated
in Listing 7-9.


Figure 7-20. Creating a domain class using GGTS

Free download pdf