Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 1. Grails in a hurry... > Improving the architecture - Pg. 24

24 C HAPTER 1 Grails in a hurry... Entries in the constraints closure also affect the generated scaffolds. For exam- ple, the ordering of entries in the constraints closure also affects the order of the fields in generated pages. Fields with constraint sizes greater than 255 characters are rendered as HTML TEXTAREA s rather than TEXT fields. Figure 1.12 shows how error mes- sages display when constraints are violated. Figure 1.12 When constraints are violated, error messages appear in red. 1.6 Improving the architecture Spreading logic across our controller actions is all well and good. It's pretty easy to track down what goes where in our small app, and maintenance isn't a concern right now. But as our quotation app grows, we'll find that things get a little more com- plex. We'll want to reuse logic in different controller actions, and even across con- trollers. It's time to tidy up our business logic, and the best way to do that in Grails is via a service. Let's create our service and learn by doing: grails create-service quote This command creates a skeleton quote service in /grails-app/services/Quote- Service.groovy: class QuoteService { boolean transactional = true def serviceMethod() { } }