SlideShare a Scribd company logo
1 of 25
Agenda
• What’s Grails?
• Getting started
• MVC
   Model: transparent Hibernate persistence
   View: GSP, layout with SiteMesh,
             dynamic tag libs
   Controller

Demo
●
What’s Grails?




  Grails is a modern MVC Web
            framework

Initially inspired by Ruby on Rails

 Convention over configuration
Productivity graph




                     AfterThought planning results
“Good Programmers Are Lazy and Dumb”
                                Philipp Lenssen
Rock-Solid Foundation




SiteMesh
●   “Groovy is what Java would look like had it been written
    in the 21st century.”
●   an agile and dynamic language for the JVM
●   inspired by languages like Python, Ruby and Smalltalk
●   compiles straight to Java bytecode, integrates natively
    with java
●   compiled or interpreted
●   supports Domain-Specific Languages and other
    compact syntax
Model

• Model backed by GORM
• The model is just a set POGOs
● Scaffolding

 class Book {
    String title
    String author
    String publisher
 }
Dynamic Persistence Methods


Static methods:
  • Book.get(1)
  • Book.find()               Instance methods:
  • Book.findAll()               • book.save()
  ● Book.findByTitleLike...
                                 • book.validate()
  ● etc
                                 • book.update()
                                 • book.delete()
                                ● boook.addTo...

                                ● book.removeFrom..
Adding constraints to your model



• Many constraints available:
blank, creditcard, email, inList, length, min,
minLength, minSize, matches, max, maxLengths,
maxSize, notEqual, nullable, range, size,
unique, url, validator

• And you can create your own closure
validator:
even( validator: { it % 2 == 0 } )
Querying your model




●Dynamic finder methods
●Query by example

●Criteria builders

●Full-blown HQL queries
Dynamic finder methods

• Book.findByTitle("The Stand")

Book.findByTitleLike("Harry Pot%")
Book.findByReleaseDateBetween(start, end)
Book.findByTitleLikeOrReleaseDateLessThan(
"%Grails%", someDate)

• Find by relationship
Book.findAllByAuthor( Author.get(1) )

• Affect sorting
Book.findAllByAuthor(me, [sort:'title',order:'asc'])
Query by example




Use the find() method and pass it an example
Instance:

Book.find( new Book(title:'The Shining') )
Criteria builder

• A builder is an arbitrary tree structure used for DSL

def c = Account.createCriteria()
def results = c {
    like("holderFirstName", "Fred%")
    and {
       between("balance", 500, 1000)
       eq("branch", "London")
    }
    maxResults(10)
    order("holderLastName", "desc")
}.list()
HQL queries


• When dynamic finders, query by example or
criteria builders don’t cut it

Book.find( "from Book as b where b.title like 'Lord of%'")

Book.find("from Book as b where b.title like ?",["The Shi%"])
Controllers

• URL mapping convention: controller/action/id
http://localhost:8080/library/book/show/1

• Scaffolding can be
      dynamic (def scaffold = true)
      static (code generation)

•   Controllers pass data to the view through maps
•   Direct access to parameters
•   Easy redirect and forward
•   Can define allowed methods for each action
Services
• Services are Groovy classes that
should contain your business logic
• Automatic injection of services in
controllers & services simply by declaring
a field:

class BookController {
  MySuperService mySuperService
}
Scheduling Jobs
• You can create recuring events with Quartz
under the hood, configured by Spring
• Again a convention on name and directory
• Regular intervals, or cron definitions

class MyJob {
  def cronExpression = "0 0 24 * * ?"
  def execute() {
    print "Job run!"
  }
}
Views

• Spring MVC under the hood
• Support for flash scope between requests
• GSP: Groovy alternative to JSP
• Dynamic taglib development: no TLD, no
configuration, just conventions
• Adaptive AJAX tags (Yahoo, Dojo, Prototype)
• Customizable layout with SiteMesh
• Page fragments through reusable templates
• Views under grails-app/views
Rich set of Dynamic Taglibs

• Logical: if, else, elseif
• Iterative: while, each, collect, findAll…
• Linking: link, createLink, createLinkTo
• Ajax: remoteFunction, remoteLink, formRemote,
submitToRemote…
• Form: form, select, currencySelect, localeSelect,
datePicker, checkBox…
• Rendering: render*, layout*, paginate…
• Validation: eachError, hasError, message
• UI: richTextEditor…
Protect your investment!
• Reuse
    Existing Java libraries
    Employee skills & knowledge
    Spring configured beans
    Hibernate mappings for legacy schemas
    (but still benefit from dynamic finders)
    EJB3 annotated mapped beans
    JSPs, taglibs for the view

• Deploy on your Java app-server & database

• Grails will fit in your JEE enterprise architecture!
No more slides !!!
Questions
Grails

More Related Content

What's hot

MongoDB at FrozenRails
MongoDB at FrozenRailsMongoDB at FrozenRails
MongoDB at FrozenRailsMike Dirolf
 
MongoDB Hadoop DC
MongoDB Hadoop DCMongoDB Hadoop DC
MongoDB Hadoop DCMike Dirolf
 
Means stack course in pune(etlhive)
Means stack course in pune(etlhive)Means stack course in pune(etlhive)
Means stack course in pune(etlhive)sambhajimeher
 
9 Months Web Development Diploma Course in North Delhi
9 Months Web Development Diploma Course in North Delhi9 Months Web Development Diploma Course in North Delhi
9 Months Web Development Diploma Course in North DelhiJessica Smith
 
GR8Conf 2011: Building Progressive UIs with Grails
GR8Conf 2011: Building Progressive UIs with GrailsGR8Conf 2011: Building Progressive UIs with Grails
GR8Conf 2011: Building Progressive UIs with GrailsGR8Conf
 
Dotnet content
Dotnet contentDotnet content
Dotnet contentmaheshcs1
 
mongodb-brief-intro-february-2012
mongodb-brief-intro-february-2012mongodb-brief-intro-february-2012
mongodb-brief-intro-february-2012Chris Westin
 
JavaScript Frameworks for SharePoint add-ins Cambridge
JavaScript Frameworks for SharePoint add-ins CambridgeJavaScript Frameworks for SharePoint add-ins Cambridge
JavaScript Frameworks for SharePoint add-ins CambridgeSonja Madsen
 

What's hot (20)

Nodejs Training in Hyderabad
Nodejs Training in HyderabadNodejs Training in Hyderabad
Nodejs Training in Hyderabad
 
MongoDB at FrozenRails
MongoDB at FrozenRailsMongoDB at FrozenRails
MongoDB at FrozenRails
 
MongoDB Hadoop DC
MongoDB Hadoop DCMongoDB Hadoop DC
MongoDB Hadoop DC
 
Means stack course in pune(etlhive)
Means stack course in pune(etlhive)Means stack course in pune(etlhive)
Means stack course in pune(etlhive)
 
Rubyandrails
RubyandrailsRubyandrails
Rubyandrails
 
Php mysql online training
Php mysql online trainingPhp mysql online training
Php mysql online training
 
9 Months Web Development Diploma Course in North Delhi
9 Months Web Development Diploma Course in North Delhi9 Months Web Development Diploma Course in North Delhi
9 Months Web Development Diploma Course in North Delhi
 
MongoDB at RuPy
MongoDB at RuPyMongoDB at RuPy
MongoDB at RuPy
 
GR8Conf 2011: Building Progressive UIs with Grails
GR8Conf 2011: Building Progressive UIs with GrailsGR8Conf 2011: Building Progressive UIs with Grails
GR8Conf 2011: Building Progressive UIs with Grails
 
Net online training
Net online trainingNet online training
Net online training
 
AngularJS
AngularJSAngularJS
AngularJS
 
Grails and Neo4j
Grails and Neo4jGrails and Neo4j
Grails and Neo4j
 
Dotnet content
Dotnet contentDotnet content
Dotnet content
 
mongodb-brief-intro-february-2012
mongodb-brief-intro-february-2012mongodb-brief-intro-february-2012
mongodb-brief-intro-february-2012
 
Php Online Training
Php Online TrainingPhp Online Training
Php Online Training
 
Aleact
AleactAleact
Aleact
 
mongodb_Introduction
mongodb_Introductionmongodb_Introduction
mongodb_Introduction
 
Php course
Php coursePhp course
Php course
 
JavaScript Frameworks for SharePoint add-ins Cambridge
JavaScript Frameworks for SharePoint add-ins CambridgeJavaScript Frameworks for SharePoint add-ins Cambridge
JavaScript Frameworks for SharePoint add-ins Cambridge
 
Client storage
Client storageClient storage
Client storage
 

Viewers also liked

Maven beyond hello_world
Maven beyond hello_worldMaven beyond hello_world
Maven beyond hello_worldGabriel Dogaru
 
Modern Rapid Application Development - Too good to be true
Modern Rapid Application Development - Too good to be trueModern Rapid Application Development - Too good to be true
Modern Rapid Application Development - Too good to be trueWaveMaker, Inc.
 

Viewers also liked (8)

Building at a glance
Building at a glanceBuilding at a glance
Building at a glance
 
Android Made Simple
Android Made SimpleAndroid Made Simple
Android Made Simple
 
Maven beyond hello_world
Maven beyond hello_worldMaven beyond hello_world
Maven beyond hello_world
 
WaveMaker Presentation
WaveMaker PresentationWaveMaker Presentation
WaveMaker Presentation
 
Android Pro Recipes
Android Pro RecipesAndroid Pro Recipes
Android Pro Recipes
 
The Groovy Way
The Groovy WayThe Groovy Way
The Groovy Way
 
Modern Rapid Application Development - Too good to be true
Modern Rapid Application Development - Too good to be trueModern Rapid Application Development - Too good to be true
Modern Rapid Application Development - Too good to be true
 
How to define an api
How to define an apiHow to define an api
How to define an api
 

Similar to Grails

OrigoDB - take the red pill
OrigoDB - take the red pillOrigoDB - take the red pill
OrigoDB - take the red pillRobert Friberg
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBSean Laurent
 
Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScriptkoppenolski
 
Incremental DOM and Recent Trend of Frontend Development
Incremental DOM and Recent Trend of Frontend DevelopmentIncremental DOM and Recent Trend of Frontend Development
Incremental DOM and Recent Trend of Frontend DevelopmentAkihiro Ikezoe
 
Raffaele Rialdi
Raffaele RialdiRaffaele Rialdi
Raffaele RialdiCodeFest
 
Edy Dawson Notes on SF HTML5 Dev Conf
Edy Dawson Notes on SF HTML5 Dev ConfEdy Dawson Notes on SF HTML5 Dev Conf
Edy Dawson Notes on SF HTML5 Dev ConfEdy Dawson
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and ActivatorKevin Webber
 
Become a Full Stack Web Developer (.NET) - Thisiswali
Become a Full Stack Web Developer (.NET) - ThisiswaliBecome a Full Stack Web Developer (.NET) - Thisiswali
Become a Full Stack Web Developer (.NET) - Thisiswalithisiswali
 
Women Who Code, Ground Floor
Women Who Code, Ground FloorWomen Who Code, Ground Floor
Women Who Code, Ground FloorKatie Weiss
 
JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)jeresig
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDCMike Dirolf
 
GR8Conf 2009: Practical Groovy DSL by Guillaume Laforge
GR8Conf 2009: Practical Groovy DSL by Guillaume LaforgeGR8Conf 2009: Practical Groovy DSL by Guillaume Laforge
GR8Conf 2009: Practical Groovy DSL by Guillaume LaforgeGR8Conf
 
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
 
Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)Chris Richardson
 
Javascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to TitaniumJavascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to TitaniumTechday7
 
Masterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsMasterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsFabian Jakobs
 
td_mxc_rubyrails_shin
td_mxc_rubyrails_shintd_mxc_rubyrails_shin
td_mxc_rubyrails_shintutorialsruby
 
td_mxc_rubyrails_shin
td_mxc_rubyrails_shintd_mxc_rubyrails_shin
td_mxc_rubyrails_shintutorialsruby
 

Similar to Grails (20)

OrigoDB - take the red pill
OrigoDB - take the red pillOrigoDB - take the red pill
OrigoDB - take the red pill
 
No sql Database
No sql DatabaseNo sql Database
No sql Database
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScript
 
Incremental DOM and Recent Trend of Frontend Development
Incremental DOM and Recent Trend of Frontend DevelopmentIncremental DOM and Recent Trend of Frontend Development
Incremental DOM and Recent Trend of Frontend Development
 
Raffaele Rialdi
Raffaele RialdiRaffaele Rialdi
Raffaele Rialdi
 
Edy Dawson Notes on SF HTML5 Dev Conf
Edy Dawson Notes on SF HTML5 Dev ConfEdy Dawson Notes on SF HTML5 Dev Conf
Edy Dawson Notes on SF HTML5 Dev Conf
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 
Become a Full Stack Web Developer (.NET) - Thisiswali
Become a Full Stack Web Developer (.NET) - ThisiswaliBecome a Full Stack Web Developer (.NET) - Thisiswali
Become a Full Stack Web Developer (.NET) - Thisiswali
 
Ruby on the JVM
Ruby on the JVMRuby on the JVM
Ruby on the JVM
 
Women Who Code, Ground Floor
Women Who Code, Ground FloorWomen Who Code, Ground Floor
Women Who Code, Ground Floor
 
JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDC
 
GR8Conf 2009: Practical Groovy DSL by Guillaume Laforge
GR8Conf 2009: Practical Groovy DSL by Guillaume LaforgeGR8Conf 2009: Practical Groovy DSL by Guillaume Laforge
GR8Conf 2009: Practical Groovy DSL by Guillaume Laforge
 
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
 
Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)
 
Javascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to TitaniumJavascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to Titanium
 
Masterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsMasterin Large Scale Java Script Applications
Masterin Large Scale Java Script Applications
 
td_mxc_rubyrails_shin
td_mxc_rubyrails_shintd_mxc_rubyrails_shin
td_mxc_rubyrails_shin
 
td_mxc_rubyrails_shin
td_mxc_rubyrails_shintd_mxc_rubyrails_shin
td_mxc_rubyrails_shin
 

Recently uploaded

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Recently uploaded (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Grails

  • 1.
  • 2. Agenda • What’s Grails? • Getting started • MVC Model: transparent Hibernate persistence View: GSP, layout with SiteMesh, dynamic tag libs Controller Demo ●
  • 3. What’s Grails? Grails is a modern MVC Web framework Initially inspired by Ruby on Rails Convention over configuration
  • 4. Productivity graph AfterThought planning results
  • 5. “Good Programmers Are Lazy and Dumb” Philipp Lenssen
  • 7. “Groovy is what Java would look like had it been written in the 21st century.” ● an agile and dynamic language for the JVM ● inspired by languages like Python, Ruby and Smalltalk ● compiles straight to Java bytecode, integrates natively with java ● compiled or interpreted ● supports Domain-Specific Languages and other compact syntax
  • 8. Model • Model backed by GORM • The model is just a set POGOs ● Scaffolding class Book { String title String author String publisher }
  • 9.
  • 10. Dynamic Persistence Methods Static methods: • Book.get(1) • Book.find() Instance methods: • Book.findAll() • book.save() ● Book.findByTitleLike... • book.validate() ● etc • book.update() • book.delete() ● boook.addTo... ● book.removeFrom..
  • 11. Adding constraints to your model • Many constraints available: blank, creditcard, email, inList, length, min, minLength, minSize, matches, max, maxLengths, maxSize, notEqual, nullable, range, size, unique, url, validator • And you can create your own closure validator: even( validator: { it % 2 == 0 } )
  • 12. Querying your model ●Dynamic finder methods ●Query by example ●Criteria builders ●Full-blown HQL queries
  • 13. Dynamic finder methods • Book.findByTitle("The Stand") Book.findByTitleLike("Harry Pot%") Book.findByReleaseDateBetween(start, end) Book.findByTitleLikeOrReleaseDateLessThan( "%Grails%", someDate) • Find by relationship Book.findAllByAuthor( Author.get(1) ) • Affect sorting Book.findAllByAuthor(me, [sort:'title',order:'asc'])
  • 14. Query by example Use the find() method and pass it an example Instance: Book.find( new Book(title:'The Shining') )
  • 15. Criteria builder • A builder is an arbitrary tree structure used for DSL def c = Account.createCriteria() def results = c { like("holderFirstName", "Fred%") and { between("balance", 500, 1000) eq("branch", "London") } maxResults(10) order("holderLastName", "desc") }.list()
  • 16. HQL queries • When dynamic finders, query by example or criteria builders don’t cut it Book.find( "from Book as b where b.title like 'Lord of%'") Book.find("from Book as b where b.title like ?",["The Shi%"])
  • 17. Controllers • URL mapping convention: controller/action/id http://localhost:8080/library/book/show/1 • Scaffolding can be dynamic (def scaffold = true) static (code generation) • Controllers pass data to the view through maps • Direct access to parameters • Easy redirect and forward • Can define allowed methods for each action
  • 18. Services • Services are Groovy classes that should contain your business logic • Automatic injection of services in controllers & services simply by declaring a field: class BookController { MySuperService mySuperService }
  • 19. Scheduling Jobs • You can create recuring events with Quartz under the hood, configured by Spring • Again a convention on name and directory • Regular intervals, or cron definitions class MyJob { def cronExpression = "0 0 24 * * ?" def execute() { print "Job run!" } }
  • 20. Views • Spring MVC under the hood • Support for flash scope between requests • GSP: Groovy alternative to JSP • Dynamic taglib development: no TLD, no configuration, just conventions • Adaptive AJAX tags (Yahoo, Dojo, Prototype) • Customizable layout with SiteMesh • Page fragments through reusable templates • Views under grails-app/views
  • 21. Rich set of Dynamic Taglibs • Logical: if, else, elseif • Iterative: while, each, collect, findAll… • Linking: link, createLink, createLinkTo • Ajax: remoteFunction, remoteLink, formRemote, submitToRemote… • Form: form, select, currencySelect, localeSelect, datePicker, checkBox… • Rendering: render*, layout*, paginate… • Validation: eachError, hasError, message • UI: richTextEditor…
  • 22. Protect your investment! • Reuse Existing Java libraries Employee skills & knowledge Spring configured beans Hibernate mappings for legacy schemas (but still benefit from dynamic finders) EJB3 annotated mapped beans JSPs, taglibs for the view • Deploy on your Java app-server & database • Grails will fit in your JEE enterprise architecture!