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

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 

Recently uploaded (20)

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 

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!