Geeks With Blogs
Zakaria's Blog July 2014 Entries
Grails Basic-Controllers(Part 4)
Command ObjectsGrails controllers support the concept of command objects. A command object is a class that is used in conjunction binding, usually to allow validation of data that may not fit into an existing domain class.Declaring Command ObjectsCommand object classes are defined just like any other class. @grails.validation.Validate... class LoginCommand { String username String password static constraints = { username(blank: false, minSize: 6) password(blank: false, minSize: 6) } } In this example, ......

Posted On Sunday, July 6, 2014 3:04 PM

Grails Basic-Controllers(Part 3)
XML and JSON ResponsesUsing the render method to output XMLGrails supports a few different ways to produce XML and JSON responses. The first is the render method.The render method can be passed a block of code to do mark-up building in XML : def list() { def results = Book.list() render(contentType: "text/xml") { books { for (b in results) { book(title: b.title) } } } } The result of this code would be something like : <books> <book title="The Stand" /> <book title="The Shining" /> ......

Posted On Sunday, July 6, 2014 2:23 PM

Grails Basic-Controllers(Part 2)
Redirects and ChainingRedirectsActions can be redirected using the redirect controller method : class OverviewController { def login() {} def find() { if (!session.user) redirect(action: 'login') return } … } } Internally the redirect method uses the HttpServletResponse object's sendRedirect method.The redirect method expects one of :Another closure within the same controller class : // Call the login action within the same class redirect(action: login) The name of an action (and controller name ......

Posted On Sunday, July 6, 2014 11:54 AM

An MVC Web Application with Grails
Anatomy of a Grails AppIn this section, we will get a better understanding of the Grails application structure. As we mentioned earlier, Grails prefers convention over configuration, therefore the location of files defines their purpose. Let’s see what we have in the grails-app directory:assets – a place where we store static assets files like styles, javascript files or imagesconf – contains project configuration files:application.yml contains standard web app settings like data source, mime types, ......

Posted On Sunday, July 6, 2014 10:56 AM

Copyright © A.K.M. Zakaria | Powered by: GeeksWithBlogs.net