-
Book Overview & Buying
-
Table Of Contents
Grails 1.1 Web Application Development
By :
You have now created a page that users can enter message data into. The next step is to handle the information that is submitted from this page. The operations you need to perform when the data is received are as follows:
1. Convert the data from an HTTP request into your domain model
2. Validate whether the information entered is acceptable for the application
3. If there are problems with the information, stop executing and let the user know what the problems were
4. If the data is acceptable, persist the data to the database
5. Inform the user that the information has been saved
This is the sort of thing that slows down the development of the web application, but with Grails, it really is a breeze. Make the following highlighted changes to MessageController.groovy:
package app
class MessageController {
def create = {
return [ message: new Message() ]
}
def save = {
def message = new Message( params )
if( !message.hasErrors() && message.save() ) {
flash.toUser ...
Change the font size
Change margin width
Change background colour