-
Book Overview & Buying
-
Table Of Contents
Grails 1.1 Web Application Development
By :
The very first thing you need to do is create a domain class to represent messages so that they can be saved to the database. You saw how to create domain classes in Chapter 2. Go to the grails-app/domain/app directory and create a file called Message.groovy and then add the following code to this file:
package app
class Message {
String title
String detail
Date dateCreated
Date lastUpdated
static constraints = {
title( blank: false, size: 1..50 )
detail( blank: false )
dateCreated( nullable: true )
lastUpdated( nullable: true )
}
}
There is nothing in the above code that is unfamiliar. But let's have a recap anyway. You have created a Groovy class called Message with the following properties:
title —the title of the message
detail —the details of the message
dateCreated —the date on which the message was created
lastUpdated —the date on which the message was last updated
You have also specified that the title cannot be blank and must be between 1 and 50 characters...
Change the font size
Change margin width
Change background colour