SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
Introduction to 
Łukasz Tenerowicz 
lukasz.tenerowicz@gmail.com 
lukasz.tenerowicz@itsilesia.com
Disadvantages of web apps in Java ? 
● Hard configuration (e.g. XML soup ) 
● Large amounts of boilerplate code ( vs. 
scripting languages like PHP, Python) 
itsilesia.com e: info@itsilesia.com
Grails = No disadvantages of Java 
● Convention over configuration - like in 
RoR 
● Groovy as a primary language 
○ Short syntax 
○ Easy! 
○ Functional elements 
● Configuration also in Groovy 
itsilesia.com e: info@itsilesia.com
… + its advantages 
● Lots of libraries 
○ Spring ( DI, Transactions, Spring Security ) 
○ Hibernate 
○ Quartz 
○ Lots of APIs ( e.g. Amazon Web Services Java 
SDK) 
● Deployment via .war file 
● ~20 years of JVM development 
itsilesia.com e: info@itsilesia.com
About Grails 
● version 1.0 in 2008 
● Looks similar to Ruby on Rails 
○ MVC 
○ convention over configuration 
○ console 
● Based on Spring MVC, Hibernate 
● Used in LinkedIn, Netflix, Sky TV, 
Vodafone 
itsilesia.com e: info@itsilesia.com
Folder structure source : https://grails.org/Quick+Start 
itsilesia.com e: info@itsilesia.com
Our first task will be ...
Hello World! 
What else ? :D
Controller 
itsilesia.com e: info@itsilesia.com 
● Class name and 
method name maps to 
an URL 
○ /hello/index 
○ /hello/show
Controller - parameters 
● URL parameters are mapped to method 
arguments 
itsilesia.com e: info@itsilesia.com 
● Also accessible 
from params map
Hello world! 
● render(“Hello world”) 
● render(“Hello “ + user) 
● Views! ${user} 
● render(view: ‘index’, model: [user: ‘user’]) 
● return [user: ‘user’] 
● redirect(action: ‘index’) 
● GSP -> g:if, g:each 
itsilesia.com e: info@itsilesia.com
But that’s all static HTML... 
Give me the DB!
Domain classes 
What our application is all about
Domain classes 
● Mapped to database via GORM 
○ Class is table, property is column 
● Constraints 
○ nullable, unique, blank, size, ... 
● Relations 
○ hasMany, belongsTo 
● Properties 
itsilesia.com e: info@itsilesia.com
Domain classes - constraints 
itsilesia.com e: info@itsilesia.com
Domain classes - relationships 
itsilesia.com e: info@itsilesia.com
Domain classes - properties 
itsilesia.com e: info@itsilesia.com
Domain class: finders and other functions 
● Person.findByName(‘asdf’) 
○ Person.findByNameAndAge(‘asdf’, 16) 
○ Person.findAllBy...And… 
● Person.save() 
○ Person.discard() 
○ Person.refresh() 
itsilesia.com e: info@itsilesia.com
Data binding 
Powerful!!!
Databinding of a domain class 
itsilesia.com e: info@itsilesia.com
Validation 
● Domains and all classes with 
@Validateable 
● Occurs on obj.validate() or during 
databinding 
● If any constraints are violated, error 
codes are added to obj.errors map 
● Those errors can be rendered via i18n 
codes 
itsilesia.com e: info@itsilesia.com
Internationalisation - i18n 
● Based on codes found in /grails-app/ 
i18n/messages.properties 
● Tags : <g:message code=”com.some.code” /> 
● So yes, we can render errors too! 
○ <g:message error=”${object.errors}” /> 
itsilesia.com e: info@itsilesia.com
Dependency 
Injection 
Easier than ever!
Other features 
Maybe next workshops :P
Other features 
● REST controllers - http://grails. 
org/doc/latest/guide/webServices.html 
● Spring Security - http://grails.org/plugin/spring-security-core 
● Database migrations - http://grails.org/plugin/database-migration 
itsilesia.com e: info@itsilesia.com
Thank you! 
Questions ?

Weitere ähnliche Inhalte

Was ist angesagt?

HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation
Linaro
 

Was ist angesagt? (12)

HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation
 
WSDM Cup 2017: Vandalism Detection
WSDM Cup 2017: Vandalism DetectionWSDM Cup 2017: Vandalism Detection
WSDM Cup 2017: Vandalism Detection
 
CIKM Cup 2016: Cross-Device Linking
CIKM Cup 2016: Cross-Device LinkingCIKM Cup 2016: Cross-Device Linking
CIKM Cup 2016: Cross-Device Linking
 
Redis 맛보기
Redis 맛보기Redis 맛보기
Redis 맛보기
 
The Appy Hour
The Appy HourThe Appy Hour
The Appy Hour
 
Hadoop @ eBuddy
Hadoop @ eBuddyHadoop @ eBuddy
Hadoop @ eBuddy
 
Large Scale Vandalism Detection in Knowledge Bases: PyData Berlin 2017
Large Scale Vandalism Detection in Knowledge Bases: PyData Berlin 2017Large Scale Vandalism Detection in Knowledge Bases: PyData Berlin 2017
Large Scale Vandalism Detection in Knowledge Bases: PyData Berlin 2017
 
Kickstarting Your Mongo Education with MongoDB University
Kickstarting Your Mongo Education with MongoDB UniversityKickstarting Your Mongo Education with MongoDB University
Kickstarting Your Mongo Education with MongoDB University
 
Marco Cecconi, Software Developer @ Stack Exchange - The architecture of Stac...
Marco Cecconi, Software Developer @ Stack Exchange - The architecture of Stac...Marco Cecconi, Software Developer @ Stack Exchange - The architecture of Stac...
Marco Cecconi, Software Developer @ Stack Exchange - The architecture of Stac...
 
Neo4j: Graph-like power
Neo4j: Graph-like powerNeo4j: Graph-like power
Neo4j: Graph-like power
 
Avito Duplicate Ads Detection @ kaggle
Avito Duplicate Ads Detection @ kaggleAvito Duplicate Ads Detection @ kaggle
Avito Duplicate Ads Detection @ kaggle
 
Big Data Day LA 2015 - How to model anything in Redis by Josiah Carlson of Ze...
Big Data Day LA 2015 - How to model anything in Redis by Josiah Carlson of Ze...Big Data Day LA 2015 - How to model anything in Redis by Josiah Carlson of Ze...
Big Data Day LA 2015 - How to model anything in Redis by Josiah Carlson of Ze...
 

Ähnlich wie Grails workshops

HTML5 New Features and Resources
HTML5 New Features and ResourcesHTML5 New Features and Resources
HTML5 New Features and Resources
Ron Reiter
 
JRuby: Pushing the Java Platform Further
JRuby: Pushing the Java Platform FurtherJRuby: Pushing the Java Platform Further
JRuby: Pushing the Java Platform Further
Charles Nutter
 
Big Data in 200 km/h | AWS Big Data Demystified #1.3
Big Data in 200 km/h | AWS Big Data Demystified #1.3  Big Data in 200 km/h | AWS Big Data Demystified #1.3
Big Data in 200 km/h | AWS Big Data Demystified #1.3
Omid Vahdaty
 

Ähnlich wie Grails workshops (20)

Dart the better Javascript 2015
Dart the better Javascript 2015Dart the better Javascript 2015
Dart the better Javascript 2015
 
Ln monitoring repositories
Ln monitoring repositoriesLn monitoring repositories
Ln monitoring repositories
 
Labeling all the Things with the WDI Skill Labeler
Labeling all the Things with the WDI Skill Labeler Labeling all the Things with the WDI Skill Labeler
Labeling all the Things with the WDI Skill Labeler
 
Front-End Developer's Career Roadmap
Front-End Developer's Career RoadmapFront-End Developer's Career Roadmap
Front-End Developer's Career Roadmap
 
JavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web frameworkJavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web framework
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScript
 
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
PGConf APAC 2018 - High performance json  postgre-sql vs. mongodbPGConf APAC 2018 - High performance json  postgre-sql vs. mongodb
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
 
Life in CSE.pptx
Life in CSE.pptxLife in CSE.pptx
Life in CSE.pptx
 
Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ...
 Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ... Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ...
Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ...
 
TinkerPop 2020
TinkerPop 2020TinkerPop 2020
TinkerPop 2020
 
HTML5 New Features and Resources
HTML5 New Features and ResourcesHTML5 New Features and Resources
HTML5 New Features and Resources
 
Ballerina Tutorial @ SummerSOC 2019
Ballerina Tutorial @ SummerSOC 2019Ballerina Tutorial @ SummerSOC 2019
Ballerina Tutorial @ SummerSOC 2019
 
Andriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsAndriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tips
 
Python for PHP developers
Python for PHP developersPython for PHP developers
Python for PHP developers
 
Ledingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @LendingkartLedingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @Lendingkart
 
JRuby: Pushing the Java Platform Further
JRuby: Pushing the Java Platform FurtherJRuby: Pushing the Java Platform Further
JRuby: Pushing the Java Platform Further
 
Parallel programing in web applications - public.pptx
Parallel programing in web applications - public.pptxParallel programing in web applications - public.pptx
Parallel programing in web applications - public.pptx
 
BUD17-302: LLVM Internals #2
BUD17-302: LLVM Internals #2 BUD17-302: LLVM Internals #2
BUD17-302: LLVM Internals #2
 
Big Data in 200 km/h | AWS Big Data Demystified #1.3
Big Data in 200 km/h | AWS Big Data Demystified #1.3  Big Data in 200 km/h | AWS Big Data Demystified #1.3
Big Data in 200 km/h | AWS Big Data Demystified #1.3
 
Learn TypeScript from scratch
Learn TypeScript from scratchLearn TypeScript from scratch
Learn TypeScript from scratch
 

Kürzlich hochgeladen

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 

Kürzlich hochgeladen (20)

Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 

Grails workshops

  • 1. Introduction to Łukasz Tenerowicz lukasz.tenerowicz@gmail.com lukasz.tenerowicz@itsilesia.com
  • 2. Disadvantages of web apps in Java ? ● Hard configuration (e.g. XML soup ) ● Large amounts of boilerplate code ( vs. scripting languages like PHP, Python) itsilesia.com e: info@itsilesia.com
  • 3. Grails = No disadvantages of Java ● Convention over configuration - like in RoR ● Groovy as a primary language ○ Short syntax ○ Easy! ○ Functional elements ● Configuration also in Groovy itsilesia.com e: info@itsilesia.com
  • 4. … + its advantages ● Lots of libraries ○ Spring ( DI, Transactions, Spring Security ) ○ Hibernate ○ Quartz ○ Lots of APIs ( e.g. Amazon Web Services Java SDK) ● Deployment via .war file ● ~20 years of JVM development itsilesia.com e: info@itsilesia.com
  • 5. About Grails ● version 1.0 in 2008 ● Looks similar to Ruby on Rails ○ MVC ○ convention over configuration ○ console ● Based on Spring MVC, Hibernate ● Used in LinkedIn, Netflix, Sky TV, Vodafone itsilesia.com e: info@itsilesia.com
  • 6. Folder structure source : https://grails.org/Quick+Start itsilesia.com e: info@itsilesia.com
  • 7. Our first task will be ...
  • 8. Hello World! What else ? :D
  • 9. Controller itsilesia.com e: info@itsilesia.com ● Class name and method name maps to an URL ○ /hello/index ○ /hello/show
  • 10. Controller - parameters ● URL parameters are mapped to method arguments itsilesia.com e: info@itsilesia.com ● Also accessible from params map
  • 11. Hello world! ● render(“Hello world”) ● render(“Hello “ + user) ● Views! ${user} ● render(view: ‘index’, model: [user: ‘user’]) ● return [user: ‘user’] ● redirect(action: ‘index’) ● GSP -> g:if, g:each itsilesia.com e: info@itsilesia.com
  • 12. But that’s all static HTML... Give me the DB!
  • 13. Domain classes What our application is all about
  • 14. Domain classes ● Mapped to database via GORM ○ Class is table, property is column ● Constraints ○ nullable, unique, blank, size, ... ● Relations ○ hasMany, belongsTo ● Properties itsilesia.com e: info@itsilesia.com
  • 15. Domain classes - constraints itsilesia.com e: info@itsilesia.com
  • 16. Domain classes - relationships itsilesia.com e: info@itsilesia.com
  • 17. Domain classes - properties itsilesia.com e: info@itsilesia.com
  • 18. Domain class: finders and other functions ● Person.findByName(‘asdf’) ○ Person.findByNameAndAge(‘asdf’, 16) ○ Person.findAllBy...And… ● Person.save() ○ Person.discard() ○ Person.refresh() itsilesia.com e: info@itsilesia.com
  • 20. Databinding of a domain class itsilesia.com e: info@itsilesia.com
  • 21. Validation ● Domains and all classes with @Validateable ● Occurs on obj.validate() or during databinding ● If any constraints are violated, error codes are added to obj.errors map ● Those errors can be rendered via i18n codes itsilesia.com e: info@itsilesia.com
  • 22. Internationalisation - i18n ● Based on codes found in /grails-app/ i18n/messages.properties ● Tags : <g:message code=”com.some.code” /> ● So yes, we can render errors too! ○ <g:message error=”${object.errors}” /> itsilesia.com e: info@itsilesia.com
  • 24. Other features Maybe next workshops :P
  • 25. Other features ● REST controllers - http://grails. org/doc/latest/guide/webServices.html ● Spring Security - http://grails.org/plugin/spring-security-core ● Database migrations - http://grails.org/plugin/database-migration itsilesia.com e: info@itsilesia.com