SlideShare a Scribd company logo
1 of 30
An Introduction To Building
Groovy Web Applications
With Grails
Harshdeep Kaur
www.company.com
OVERVIEW
• Grails is a web application framework 
• Friendly for beginners to learn.
• Support a more agile development approach. 
• MVC framework based on Groovy/Java
• Heavily inspired on Rails framework
• But takes advantage of Java technology like
Spring and servlets
Company
LOGO
www.company.com
What is GrailsCompany
LOGO
 Grails is an open source web application framework
Built on the Java Platform
 Groovy as the primary language
Java can also be used and intermixed with Groovy
seamlessly
 Favour's Convention over Configuration
Similar in spirit to Ruby on Rails
 Grails having the following features
Rapid, Robust, Dynamic
 Powerful features
Integrated ORM / NoSQL support, a powerful view technology, plugins, and
Spring-powered dependency injection
 Domain-Specific Languages
Expressive Domain Specific Languages (DSLs) used for validation, querying,
markup rendering etc.
www.company.com
Rapid Development
As Grails is inspired by the RAILS principle, it
provides 52 commands to make your life easier:
grails create-app
grails create-domain-class
grails create-controller
grails install-plugin
grails war
www.company.com
Grails is Robust
Grails builds upon proven technology:
Groovy - open source dynamic language for the Java Virtual Machine
that offers a flexible Java-like syntax
Spring Framework - Dependency injection services
Hibernate - an Object Relational Mapping (ORM) Framework
SiteMesh - interface layout and theming facilities
+=
www.company.com
Why It Is Dynamic
• Changes made in Controllers and Views are instantly
visible - Domain Classes, Bootstrap and Configuration require a
recompile
www.company.com
Why grails
Grails aims to improve productivity over
conventional Java Frameworks by:
eliminating XML configuration - Convention over
Configuration. For example, a class name which ends with Controller (e.g.
BookController) is considered a web controller
Scaffolding: Scaffolding utilities provided by Grails is a great advantage
when building prototypes to validate the idea; or to build Admin interfaces.
ready to use development environment - Grails comes with
a complete development environment which includes a webserver and a
database
www.company.com
Model View Controller?
MVC is a software architectural pattern which dates
back to 1979 and is widely adopted. It separates:
Data - The model manages the behavior and data of the application
domain.
User Interface - The view renders the model into a form suitable for
interaction, typically a user interface element
Application Logic - The controller receives user input and initiates
a response by making calls on model objects.
www.company.com
Grails application built up
www.company.com
Domain
Classes
This will generate Domain Classes
and Unit Tests
This will generate Domain Classes
and Unit Tests
www.company.com
The Controller
This will generate Controller
Classes
www.company.com
The Views
grails generate-views [domain class]
www.company.com
Groovy Language
 Is an agile and dynamic language for the Java Virtual Machine
 Additional power features inspired by languages like Python, Ruby and
Smalltalk
 Everything is an object no primitive types.
 Optional Typing – If not explicitly specified assumed to be java.lang.Object
 Can be compiled to Java byte code
 Groovy classes are Java classes
 Lots of new languages features
GPath, GString, internal iterators, closures, Meta‐
Object Protocol (MOP), and many others
www.company.com
Groovy Syntax
Semicolons- use of semicolons ( ; ) in Groovy is completely optional .
Data type declaration-When creating an object, it’s type doesn’t have to be
defined explicitly. By using the def-keyword, Groovy will automatically detect what object
type has to be used
Groovy String- The Groovy String (Also called “GString”) allows for any type of
logic to be integrated in the String definition. This can be done with the dollar symbol
( $ ) and (optional) braces ( { } ). The difference between a String and a GString is
automatically recognized by Groovy.
www.company.com
CollectionsGroovy Syntax
Collections- Groovy acknowledges three different types of collections
Lists- are no different from the ones used in Java.
Maps- are no different from the ones used in Java.
Ranges- a range defines a start and an end point.
Loops- Because of Groovy’s origin in Java, it natively supports both the
for- and while-loop.
Groovy’s for-each loops though, have a slight difference in syntax
Groovy has some special capabilities for collections- each method
executes a given closure for each of the item the list.
www.company.com
Domain classes are central to a
Grails application
 Located in grails app/domain‐
 All attributes persistent unless
marked in the transients property
No getters and setters necessary
Validators: specified in
constraints
GORM mapping: customized in
the mapping property
Domain Model Object
www.company.com
GROM
Grails Object Relational Mapping
Leverages Hibernate
Automatically maps domain objects to database
Provides query and update facilities
Finding objects in the persistence store (findBy…
methods).
Persistence lifecycle methods (save,update,delete).
Criteria and HQL query facilities.
Declare properties for your domain objects
The id or version properties are injected
automatically.
All properties are not null/required by default
www.company.com
Grails
Object
Relational
Mapping
Grails Object Relational
Mapping
www.company.com
The Controllers
Handles HTTP requests and
determines rendering
responsibility
Many objects are available to
your controller closures log,
params , request , response
session servlet-Context ,
flash
www.company.com
The Controllers
Dynamic Scaffolding
Enable Scaffolding
www.company.com
The Service Layer
Allows for centralization of application
behavior
 Necessary component in any non trivial Grails‐
application
Transactional by default, set through the
transactional property
www.company.com
Errors and Validation
Built upon Spring’s validation framework
org.springframework.validation package
Domain objects have validation baked in
save() and validate() methods trigger validation
Validation errors populate errors property on
domain object Errors
Interrogate the domain object instance hasErrors() method and error property
def user = new User(params)
if (user.validate())
{ // do something with user }
else {
user.errors.allErrors.each { println it } }
www.company.com
Database Connectivity
 JDBC is used for communicating with databases
 HSQLDB: default data source
DataSource.groovy
Configuration of Data Sources for all your environments
www.company.com
Views And Groovy Server Pages
Similar to JSPs
Utilizes GPath and GStrings and other cool Groovy language features
Automatic discovery of Grails taglibs
Support for templates
Small snippets of view code that other views canuse
Useful for AJAX responses
www.company.com
The Views
’’ff’’ff
Form tag Go to mapping register inGo to mapping register in
customer controllercustomer controller
Go to mapping register inGo to mapping register in
customer controllercustomer controller
You can create your own tags by creating
new tag libraries
You can create your own tags by creating
new tag libraries
www.company.com
Demo of grails/groovy
Set configuration for the application through:-
1.BuildConfig.groovy
2.DataSource.groovy
Uncomment this
Add
Dependencies
and plugins
here
www.company.com
Create
Create domain class
Create Controller class
name of controller will be the same as domain class to implement COC
Demo of grails/groovy
www.company.com
Demo of grails/groovy
www.company.com
www.company.com

More Related Content

What's hot

Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code IgniterAmzad Hossain
 
Java EE and Spring Side-by-Side
Java EE and Spring Side-by-SideJava EE and Spring Side-by-Side
Java EE and Spring Side-by-SideReza Rahman
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015Hossein Zahed
 
High Performance Cloud Native APIs Using Apache Geode
High Performance Cloud Native APIs Using Apache Geode High Performance Cloud Native APIs Using Apache Geode
High Performance Cloud Native APIs Using Apache Geode VMware Tanzu
 
Angular jS Introduction by Google
Angular jS Introduction by GoogleAngular jS Introduction by Google
Angular jS Introduction by GoogleASG
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC frameworkMohit Gupta
 
ASP.NET MVC Performance
ASP.NET MVC PerformanceASP.NET MVC Performance
ASP.NET MVC Performancerudib
 
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]
26 top angular 8 interview questions to know in 2020   [www.full stack.cafe]26 top angular 8 interview questions to know in 2020   [www.full stack.cafe]
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]Alex Ershov
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVCLearnNowOnline
 
Html5 with Vaadin and Scala
Html5 with Vaadin and ScalaHtml5 with Vaadin and Scala
Html5 with Vaadin and ScalaJoonas Lehtinen
 
OSGi and Spring Data for simple (Web) Application Development
OSGi and Spring Data  for simple (Web) Application DevelopmentOSGi and Spring Data  for simple (Web) Application Development
OSGi and Spring Data for simple (Web) Application DevelopmentChristian Baranowski
 

What's hot (20)

Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code Igniter
 
Java EE and Spring Side-by-Side
Java EE and Spring Side-by-SideJava EE and Spring Side-by-Side
Java EE and Spring Side-by-Side
 
Flex in portal
Flex in portalFlex in portal
Flex in portal
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
 
High Performance Cloud Native APIs Using Apache Geode
High Performance Cloud Native APIs Using Apache Geode High Performance Cloud Native APIs Using Apache Geode
High Performance Cloud Native APIs Using Apache Geode
 
Angular jS Introduction by Google
Angular jS Introduction by GoogleAngular jS Introduction by Google
Angular jS Introduction by Google
 
Open Social Summit Korea
Open Social Summit KoreaOpen Social Summit Korea
Open Social Summit Korea
 
React-js
React-jsReact-js
React-js
 
Spring framework core
Spring framework coreSpring framework core
Spring framework core
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC framework
 
[2015/2016] Backbone JS
[2015/2016] Backbone JS[2015/2016] Backbone JS
[2015/2016] Backbone JS
 
ASP.NET MVC Performance
ASP.NET MVC PerformanceASP.NET MVC Performance
ASP.NET MVC Performance
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Asp.Net MVC Intro
Asp.Net MVC IntroAsp.Net MVC Intro
Asp.Net MVC Intro
 
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]
26 top angular 8 interview questions to know in 2020   [www.full stack.cafe]26 top angular 8 interview questions to know in 2020   [www.full stack.cafe]
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
Html5 with Vaadin and Scala
Html5 with Vaadin and ScalaHtml5 with Vaadin and Scala
Html5 with Vaadin and Scala
 
OSGi and Spring Data for simple (Web) Application Development
OSGi and Spring Data  for simple (Web) Application DevelopmentOSGi and Spring Data  for simple (Web) Application Development
OSGi and Spring Data for simple (Web) Application Development
 

Viewers also liked

Future net business_presentation_en
Future net business_presentation_enFuture net business_presentation_en
Future net business_presentation_enMake Money
 
Joseph Melito PPP
Joseph Melito PPP Joseph Melito PPP
Joseph Melito PPP JoeMelito
 
Василь Симоненко
Василь СимоненкоВасиль Симоненко
Василь СимоненкоDashichka
 
IMMERSE 2016 IST Mark Szulc Keynote
IMMERSE 2016 IST Mark Szulc KeynoteIMMERSE 2016 IST Mark Szulc Keynote
IMMERSE 2016 IST Mark Szulc KeynoteAdobeMarketingCloud
 
IMMERSE 2016 Cedric Huesler US Keynote
IMMERSE 2016 Cedric Huesler US KeynoteIMMERSE 2016 Cedric Huesler US Keynote
IMMERSE 2016 Cedric Huesler US KeynoteAdobeMarketingCloud
 
IMMERSE 2016 Introducing content fragments
IMMERSE 2016 Introducing content fragmentsIMMERSE 2016 Introducing content fragments
IMMERSE 2016 Introducing content fragmentsAdobeMarketingCloud
 
Ask the AEM Community Expert Feb 2016 Session: AEM + Brackets
Ask the AEM Community Expert Feb 2016 Session: AEM + BracketsAsk the AEM Community Expert Feb 2016 Session: AEM + Brackets
Ask the AEM Community Expert Feb 2016 Session: AEM + BracketsAdobeMarketingCloud
 
IMMERSE'16 Introduction to adobe experience manager back end
IMMERSE'16 Introduction to adobe experience manager back endIMMERSE'16 Introduction to adobe experience manager back end
IMMERSE'16 Introduction to adobe experience manager back endAdobeMarketingCloud
 
AEM GEMS Session Template Editor Sept 14 2016
AEM GEMS Session Template Editor Sept 14 2016AEM GEMS Session Template Editor Sept 14 2016
AEM GEMS Session Template Editor Sept 14 2016AdobeMarketingCloud
 
Immerse 2016 Efficient publishing with content fragments
Immerse 2016 Efficient publishing with content fragmentsImmerse 2016 Efficient publishing with content fragments
Immerse 2016 Efficient publishing with content fragmentsAdobeMarketingCloud
 
AEM GEMs Session Oak Lucene Indexes
AEM GEMs Session Oak Lucene IndexesAEM GEMs Session Oak Lucene Indexes
AEM GEMs Session Oak Lucene IndexesAdobeMarketingCloud
 
Ask the expert AEM Assets best practices 092016
Ask the expert  AEM Assets best practices 092016Ask the expert  AEM Assets best practices 092016
Ask the expert AEM Assets best practices 092016AdobeMarketingCloud
 
Build single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMBuild single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMAdobeMarketingCloud
 
Build single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMBuild single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMAdobeMarketingCloud
 
IMMERSE'16 Introduction to AEM Tooling
IMMERSE'16 Introduction to AEM ToolingIMMERSE'16 Introduction to AEM Tooling
IMMERSE'16 Introduction to AEM ToolingAdobeMarketingCloud
 
Introduction to Adobe Experience Manager based e commerce
Introduction to Adobe Experience Manager based e commerceIntroduction to Adobe Experience Manager based e commerce
Introduction to Adobe Experience Manager based e commerceAdobeMarketingCloud
 
AEM GEMS Session SAML authentication in AEM
AEM GEMS Session SAML authentication in AEMAEM GEMS Session SAML authentication in AEM
AEM GEMS Session SAML authentication in AEMAdobeMarketingCloud
 
IMMERSE'16 Intro to Adobe Experience Manager & Adobe Marketing Cloud
IMMERSE'16 Intro to Adobe Experience Manager & Adobe Marketing CloudIMMERSE'16 Intro to Adobe Experience Manager & Adobe Marketing Cloud
IMMERSE'16 Intro to Adobe Experience Manager & Adobe Marketing CloudAdobeMarketingCloud
 
Adobe Ask the AEM Community Expert Session Oct 2016
Adobe Ask the AEM Community Expert Session Oct 2016Adobe Ask the AEM Community Expert Session Oct 2016
Adobe Ask the AEM Community Expert Session Oct 2016AdobeMarketingCloud
 

Viewers also liked (19)

Future net business_presentation_en
Future net business_presentation_enFuture net business_presentation_en
Future net business_presentation_en
 
Joseph Melito PPP
Joseph Melito PPP Joseph Melito PPP
Joseph Melito PPP
 
Василь Симоненко
Василь СимоненкоВасиль Симоненко
Василь Симоненко
 
IMMERSE 2016 IST Mark Szulc Keynote
IMMERSE 2016 IST Mark Szulc KeynoteIMMERSE 2016 IST Mark Szulc Keynote
IMMERSE 2016 IST Mark Szulc Keynote
 
IMMERSE 2016 Cedric Huesler US Keynote
IMMERSE 2016 Cedric Huesler US KeynoteIMMERSE 2016 Cedric Huesler US Keynote
IMMERSE 2016 Cedric Huesler US Keynote
 
IMMERSE 2016 Introducing content fragments
IMMERSE 2016 Introducing content fragmentsIMMERSE 2016 Introducing content fragments
IMMERSE 2016 Introducing content fragments
 
Ask the AEM Community Expert Feb 2016 Session: AEM + Brackets
Ask the AEM Community Expert Feb 2016 Session: AEM + BracketsAsk the AEM Community Expert Feb 2016 Session: AEM + Brackets
Ask the AEM Community Expert Feb 2016 Session: AEM + Brackets
 
IMMERSE'16 Introduction to adobe experience manager back end
IMMERSE'16 Introduction to adobe experience manager back endIMMERSE'16 Introduction to adobe experience manager back end
IMMERSE'16 Introduction to adobe experience manager back end
 
AEM GEMS Session Template Editor Sept 14 2016
AEM GEMS Session Template Editor Sept 14 2016AEM GEMS Session Template Editor Sept 14 2016
AEM GEMS Session Template Editor Sept 14 2016
 
Immerse 2016 Efficient publishing with content fragments
Immerse 2016 Efficient publishing with content fragmentsImmerse 2016 Efficient publishing with content fragments
Immerse 2016 Efficient publishing with content fragments
 
AEM GEMs Session Oak Lucene Indexes
AEM GEMs Session Oak Lucene IndexesAEM GEMs Session Oak Lucene Indexes
AEM GEMs Session Oak Lucene Indexes
 
Ask the expert AEM Assets best practices 092016
Ask the expert  AEM Assets best practices 092016Ask the expert  AEM Assets best practices 092016
Ask the expert AEM Assets best practices 092016
 
Build single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMBuild single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEM
 
Build single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMBuild single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEM
 
IMMERSE'16 Introduction to AEM Tooling
IMMERSE'16 Introduction to AEM ToolingIMMERSE'16 Introduction to AEM Tooling
IMMERSE'16 Introduction to AEM Tooling
 
Introduction to Adobe Experience Manager based e commerce
Introduction to Adobe Experience Manager based e commerceIntroduction to Adobe Experience Manager based e commerce
Introduction to Adobe Experience Manager based e commerce
 
AEM GEMS Session SAML authentication in AEM
AEM GEMS Session SAML authentication in AEMAEM GEMS Session SAML authentication in AEM
AEM GEMS Session SAML authentication in AEM
 
IMMERSE'16 Intro to Adobe Experience Manager & Adobe Marketing Cloud
IMMERSE'16 Intro to Adobe Experience Manager & Adobe Marketing CloudIMMERSE'16 Intro to Adobe Experience Manager & Adobe Marketing Cloud
IMMERSE'16 Intro to Adobe Experience Manager & Adobe Marketing Cloud
 
Adobe Ask the AEM Community Expert Session Oct 2016
Adobe Ask the AEM Community Expert Session Oct 2016Adobe Ask the AEM Community Expert Session Oct 2016
Adobe Ask the AEM Community Expert Session Oct 2016
 

Similar to intoduction to Grails Framework

Magic with groovy & grails
Magic with groovy & grailsMagic with groovy & grails
Magic with groovy & grailsGeorge Platon
 
GROOVY ON GRAILS
GROOVY ON GRAILSGROOVY ON GRAILS
GROOVY ON GRAILSziyaaskerov
 
Groovy and Grails intro
Groovy and Grails introGroovy and Grails intro
Groovy and Grails introMiguel Pastor
 
ACADGILD:: FRONTEND LESSON -Ruby on rails vs groovy on rails
ACADGILD:: FRONTEND LESSON -Ruby on rails vs groovy on railsACADGILD:: FRONTEND LESSON -Ruby on rails vs groovy on rails
ACADGILD:: FRONTEND LESSON -Ruby on rails vs groovy on railsPadma shree. T
 
Introduction To Groovy And Grails - SpringPeople
Introduction To Groovy And Grails - SpringPeopleIntroduction To Groovy And Grails - SpringPeople
Introduction To Groovy And Grails - SpringPeopleSpringPeople
 
Introduction to Grails 2013
Introduction to Grails 2013Introduction to Grails 2013
Introduction to Grails 2013Gavin Hogan
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finessemzgubin
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finessemzgubin
 
JavaOne 2009 BOF-5189 Griffon In Depth
JavaOne 2009 BOF-5189 Griffon In DepthJavaOne 2009 BOF-5189 Griffon In Depth
JavaOne 2009 BOF-5189 Griffon In DepthDanno Ferrin
 
Griffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java TechnologyGriffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java TechnologyJames Williams
 
Global Logic sMash Overview And Experiences
Global Logic   sMash  Overview And  ExperiencesGlobal Logic   sMash  Overview And  Experiences
Global Logic sMash Overview And ExperiencesProject Zero
 
GR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting GrailsGR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting GrailsGR8Conf
 
Adopting Grails - GR8Conf Europe
Adopting Grails - GR8Conf EuropeAdopting Grails - GR8Conf Europe
Adopting Grails - GR8Conf EuropeKlausBaumecker
 
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & CucumberUdaya Kiran
 
Closure Library: Build Complex JavaScript Applications
Closure Library: Build Complex JavaScript ApplicationsClosure Library: Build Complex JavaScript Applications
Closure Library: Build Complex JavaScript Applicationsdevbilt
 
Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009Arun Gupta
 

Similar to intoduction to Grails Framework (20)

Introduction To Grails
Introduction To GrailsIntroduction To Grails
Introduction To Grails
 
Magic with groovy & grails
Magic with groovy & grailsMagic with groovy & grails
Magic with groovy & grails
 
GROOVY ON GRAILS
GROOVY ON GRAILSGROOVY ON GRAILS
GROOVY ON GRAILS
 
GROOVY ON GRAILS
GROOVY ON GRAILSGROOVY ON GRAILS
GROOVY ON GRAILS
 
Groovy and Grails intro
Groovy and Grails introGroovy and Grails intro
Groovy and Grails intro
 
ACADGILD:: FRONTEND LESSON -Ruby on rails vs groovy on rails
ACADGILD:: FRONTEND LESSON -Ruby on rails vs groovy on railsACADGILD:: FRONTEND LESSON -Ruby on rails vs groovy on rails
ACADGILD:: FRONTEND LESSON -Ruby on rails vs groovy on rails
 
Introduction To Groovy And Grails - SpringPeople
Introduction To Groovy And Grails - SpringPeopleIntroduction To Groovy And Grails - SpringPeople
Introduction To Groovy And Grails - SpringPeople
 
Introduction to Grails 2013
Introduction to Grails 2013Introduction to Grails 2013
Introduction to Grails 2013
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finesse
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finesse
 
JavaOne 2009 BOF-5189 Griffon In Depth
JavaOne 2009 BOF-5189 Griffon In DepthJavaOne 2009 BOF-5189 Griffon In Depth
JavaOne 2009 BOF-5189 Griffon In Depth
 
Grails 101
Grails 101Grails 101
Grails 101
 
Griffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java TechnologyGriffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java Technology
 
Global Logic sMash Overview And Experiences
Global Logic   sMash  Overview And  ExperiencesGlobal Logic   sMash  Overview And  Experiences
Global Logic sMash Overview And Experiences
 
GR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting GrailsGR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting Grails
 
Adopting Grails - GR8Conf Europe
Adopting Grails - GR8Conf EuropeAdopting Grails - GR8Conf Europe
Adopting Grails - GR8Conf Europe
 
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
 
Groovy & Grails
Groovy & GrailsGroovy & Grails
Groovy & Grails
 
Closure Library: Build Complex JavaScript Applications
Closure Library: Build Complex JavaScript ApplicationsClosure Library: Build Complex JavaScript Applications
Closure Library: Build Complex JavaScript Applications
 
Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009
 

Recently uploaded

Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 

Recently uploaded (20)

Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 

intoduction to Grails Framework

  • 1. An Introduction To Building Groovy Web Applications With Grails Harshdeep Kaur
  • 2. www.company.com OVERVIEW • Grails is a web application framework  • Friendly for beginners to learn. • Support a more agile development approach.  • MVC framework based on Groovy/Java • Heavily inspired on Rails framework • But takes advantage of Java technology like Spring and servlets Company LOGO
  • 3. www.company.com What is GrailsCompany LOGO  Grails is an open source web application framework Built on the Java Platform  Groovy as the primary language Java can also be used and intermixed with Groovy seamlessly  Favour's Convention over Configuration Similar in spirit to Ruby on Rails  Grails having the following features Rapid, Robust, Dynamic  Powerful features Integrated ORM / NoSQL support, a powerful view technology, plugins, and Spring-powered dependency injection  Domain-Specific Languages Expressive Domain Specific Languages (DSLs) used for validation, querying, markup rendering etc.
  • 4. www.company.com Rapid Development As Grails is inspired by the RAILS principle, it provides 52 commands to make your life easier: grails create-app grails create-domain-class grails create-controller grails install-plugin grails war
  • 5. www.company.com Grails is Robust Grails builds upon proven technology: Groovy - open source dynamic language for the Java Virtual Machine that offers a flexible Java-like syntax Spring Framework - Dependency injection services Hibernate - an Object Relational Mapping (ORM) Framework SiteMesh - interface layout and theming facilities +=
  • 6. www.company.com Why It Is Dynamic • Changes made in Controllers and Views are instantly visible - Domain Classes, Bootstrap and Configuration require a recompile
  • 7. www.company.com Why grails Grails aims to improve productivity over conventional Java Frameworks by: eliminating XML configuration - Convention over Configuration. For example, a class name which ends with Controller (e.g. BookController) is considered a web controller Scaffolding: Scaffolding utilities provided by Grails is a great advantage when building prototypes to validate the idea; or to build Admin interfaces. ready to use development environment - Grails comes with a complete development environment which includes a webserver and a database
  • 8. www.company.com Model View Controller? MVC is a software architectural pattern which dates back to 1979 and is widely adopted. It separates: Data - The model manages the behavior and data of the application domain. User Interface - The view renders the model into a form suitable for interaction, typically a user interface element Application Logic - The controller receives user input and initiates a response by making calls on model objects.
  • 10. www.company.com Domain Classes This will generate Domain Classes and Unit Tests This will generate Domain Classes and Unit Tests
  • 11. www.company.com The Controller This will generate Controller Classes
  • 13. www.company.com Groovy Language  Is an agile and dynamic language for the Java Virtual Machine  Additional power features inspired by languages like Python, Ruby and Smalltalk  Everything is an object no primitive types.  Optional Typing – If not explicitly specified assumed to be java.lang.Object  Can be compiled to Java byte code  Groovy classes are Java classes  Lots of new languages features GPath, GString, internal iterators, closures, Meta‐ Object Protocol (MOP), and many others
  • 14. www.company.com Groovy Syntax Semicolons- use of semicolons ( ; ) in Groovy is completely optional . Data type declaration-When creating an object, it’s type doesn’t have to be defined explicitly. By using the def-keyword, Groovy will automatically detect what object type has to be used Groovy String- The Groovy String (Also called “GString”) allows for any type of logic to be integrated in the String definition. This can be done with the dollar symbol ( $ ) and (optional) braces ( { } ). The difference between a String and a GString is automatically recognized by Groovy.
  • 15. www.company.com CollectionsGroovy Syntax Collections- Groovy acknowledges three different types of collections Lists- are no different from the ones used in Java. Maps- are no different from the ones used in Java. Ranges- a range defines a start and an end point. Loops- Because of Groovy’s origin in Java, it natively supports both the for- and while-loop. Groovy’s for-each loops though, have a slight difference in syntax Groovy has some special capabilities for collections- each method executes a given closure for each of the item the list.
  • 16. www.company.com Domain classes are central to a Grails application  Located in grails app/domain‐  All attributes persistent unless marked in the transients property No getters and setters necessary Validators: specified in constraints GORM mapping: customized in the mapping property Domain Model Object
  • 17. www.company.com GROM Grails Object Relational Mapping Leverages Hibernate Automatically maps domain objects to database Provides query and update facilities Finding objects in the persistence store (findBy… methods). Persistence lifecycle methods (save,update,delete). Criteria and HQL query facilities. Declare properties for your domain objects The id or version properties are injected automatically. All properties are not null/required by default
  • 19. www.company.com The Controllers Handles HTTP requests and determines rendering responsibility Many objects are available to your controller closures log, params , request , response session servlet-Context , flash
  • 21. www.company.com The Service Layer Allows for centralization of application behavior  Necessary component in any non trivial Grails‐ application Transactional by default, set through the transactional property
  • 22. www.company.com Errors and Validation Built upon Spring’s validation framework org.springframework.validation package Domain objects have validation baked in save() and validate() methods trigger validation Validation errors populate errors property on domain object Errors Interrogate the domain object instance hasErrors() method and error property def user = new User(params) if (user.validate()) { // do something with user } else { user.errors.allErrors.each { println it } }
  • 23. www.company.com Database Connectivity  JDBC is used for communicating with databases  HSQLDB: default data source DataSource.groovy Configuration of Data Sources for all your environments
  • 24. www.company.com Views And Groovy Server Pages Similar to JSPs Utilizes GPath and GStrings and other cool Groovy language features Automatic discovery of Grails taglibs Support for templates Small snippets of view code that other views canuse Useful for AJAX responses
  • 25. www.company.com The Views ’’ff’’ff Form tag Go to mapping register inGo to mapping register in customer controllercustomer controller Go to mapping register inGo to mapping register in customer controllercustomer controller You can create your own tags by creating new tag libraries You can create your own tags by creating new tag libraries
  • 26. www.company.com Demo of grails/groovy Set configuration for the application through:- 1.BuildConfig.groovy 2.DataSource.groovy Uncomment this Add Dependencies and plugins here
  • 27. www.company.com Create Create domain class Create Controller class name of controller will be the same as domain class to implement COC Demo of grails/groovy