How Grails MVC works?

Grails is an MVC platform that’s used for developing MVC applications.

The architecture and different components used in the Grails MVC application is shown as below:

Grails MVC Architecure

 

It shows the request flow on a Grails MVC application.

  • Model:

Model is a Java object which stores the data that can be used by       the controllers and views. Grails provides you a binded mechanism that help you references your model from the grails UI components like g:each.

Grails provides an inline validation in the model. Grails domain class can express domain constraints simply by defining a public static property constraints that has a closure as a value.

  • Controller:

It is a servlet which handles all the request from the front end. In general, Grails servlet extends Spring’s DispatcherServlet to bootstrap the Grails environment (SimpleGrailsController) for handling the requests. SimpleGrailsController delegates to a class called SimpleGrailsControllerHelper that actually handles the request.

A proper name for your controller must be ended with the controller phrase, that would help Grails to discover the controllers conventionally.

  • View:

Groovy server pages is responsible for rendering the models. Grails uses GroovyPagesTemplateEngine for rendering of GSP views as those views support the concept of custom tag libraries. You can access the g tags directly within your GSP without any need of importing it. A lot of ready-made tags are provided for your use. Grails g library provides you ability of accessing data binded and domain class associations.


ProsperaSoft offers Grails development solutions. You can email at info@prosperasoft.com to get in touch with ProsperaSoft Grails experts and consultants.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>