0
Grails & Groovy introducing Grails TV                    Take the tour
To do        A little about myself        Grails TV        Groovy        Grails        grails create-app
To do        A little about myself        Grails TV        Groovy        Grails        grails create-app
To do        A little about myself        Grails TV        Groovy        Grails        grails create-app
To do        A little about myself        Grails TV        Groovy        Grails        grails create-app
To do        A little about myself        Grails TV        Groovy        Grails        grails create-app
Fast Food Friday
http://www.ihenk.com            @henkjurrienshenk.jurriens@gmail.com
01 1?  LL 2FA
Groovy
package com.groovy.home;import java.io.BufferedReader;import java.io.FileNotFoundException;import java.io.FileReader;impor...
new File("test.txt").eachLine{     line -> println line}
Closures
def x = 2def c = {     numberToSquare -> numberToSquare *     numberToSquere}def y = c(x)
Collections
Listsdef list = [ 5, 6, 7, 8 ]list.each{    println it}
Mapsdef map = [ name: “henk” , likes : “cheese” ]assert map.get(“name”) == “henk”
•   find•   findAll•   sort•   sum
otherfeatures
Dynamic Methods
class Dog {  def bark() { println "woof!" }  def sit() { println "(sitting)" }  def jump() { println "boing!" }}def doActi...
XMLBuilders
def builder = newgroovy.xml.MarkupBuilder()builder.web-app {                      XMLBuilders   display-name My Web Applic...
Convention over Configuration
Simplify the life of   developers
=
=
=+
=+
=++
=++
Spring
SpringHibernate
SpringHibernateSiteMesh
SpringHibernateSiteMeshTomcat
Grails Stack  Java Virtual Machine
Grails StackJava Language                Java Virtual Machine
Grails Stack                       Java Development KitJava Language                               (JDK)                Ja...
Grails StackJava Enterprise  Edition (JEE)                             Java Development Kit      Java Language            ...
Grails StackJava Enterprise                  Spring  Edition (JEE)                             Java Development Kit      J...
Grails StackJava Enterprise                  Spring    Hibernate  Edition (JEE)                             Java Developme...
Grails StackJava Enterprise                  Spring    Hibernate        SiteMesh  Edition (JEE)                           ...
Grails StackJava Enterprise                  Spring    Hibernate        SiteMesh   Groovy  Edition (JEE)                  ...
Grails Stack                      GrailsJava Enterprise                  Spring    Hibernate        SiteMesh   Groovy  Edi...
grails create-app gtv
grails-app       domain       controllers       views       services       taglib        i18n
Wait!
Wait!Configuration files?
Wait!   Configuration files?no database to configure?
Wait!   Configuration files?no database to configure? no app server to install?
Models
class Movie {       String title       String description       String image       Integer rating       String movie}
static constraints = {   title(blank:false)   description(size:10..200)   rating(min:1, max:5)}
• blank   • inList• email   • nullable• url     • min• range   • scale
GORM
• Movie.count()   • Movie.save()• Movie.list()    • Movie.delete()• Movie.get(id)   • etc
Querying
• find        • countBy• findAllBy   • list• count      • listOrderby
def m = Movie.findByTitle(‘Star trek’)m = Movie.findByRating(4)m = Movie.     findByReleaseDateBetween(..,..)
Controllers
http://srvr:8080/app/controller/action
Movie.properties = params
Views
Groovy Server Pages
Groovy Server Pages   Grails Tag Libs
Groovy Server Pages    Grails Tag LibsTemplates, URL mapping
<g:render template="menu"/><g:each in="${content}" var="item"><g:link action="detail" id="${item.id}" >          </g:link>...
Plugins
> 500 plugins
> 500 plugins  Security &authentication
> 500 plugins  Security &authentication                 Scheduling
> 500 plugins  Security &authentication                jQuery                 Scheduling
> 500 plugins  Security &authentication                jQuery                 Scheduling           Google App Engine
> 500 plugins  Security &authentication                jQuery                 Scheduling            CouchDB           Goog...
Let’s build GTV!
http://www.grails.orghttp://groovy.codehaus.org/
Grails TV : an introduction into Grails & Groovy
Grails TV : an introduction into Grails & Groovy
Grails TV : an introduction into Grails & Groovy
Grails TV : an introduction into Grails & Groovy
Grails TV : an introduction into Grails & Groovy
Grails TV : an introduction into Grails & Groovy
Grails TV : an introduction into Grails & Groovy
Grails TV : an introduction into Grails & Groovy
Grails TV : an introduction into Grails & Groovy
Grails TV : an introduction into Grails & Groovy
Grails TV : an introduction into Grails & Groovy
Grails TV : an introduction into Grails & Groovy
Upcoming SlideShare
Loading in...5
×

Grails TV : an introduction into Grails & Groovy

1,956

Published on

An introduction into Grails & Groovy

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,956
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
43
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • Hello everybody, today I&amp;#x2019;m to going explain Grails &amp; Groovy by introducing Grails\n\n\n
  • What are we&amp;#x2019;re doing to this afternoon?\n\n- First a little bit about myself\n\n- Grails TV, what is exactly Grails TV?\n\n- introduction into Groovy\n\n- and an introduction into Grails\n\n- and finally we&amp;#x2019;re going to create an app!\n\n
  • What are we&amp;#x2019;re doing to this afternoon?\n\n- First a little bit about myself\n\n- Grails TV, what is exactly Grails TV?\n\n- introduction into Groovy\n\n- and an introduction into Grails\n\n- and finally we&amp;#x2019;re going to create an app!\n\n
  • What are we&amp;#x2019;re doing to this afternoon?\n\n- First a little bit about myself\n\n- Grails TV, what is exactly Grails TV?\n\n- introduction into Groovy\n\n- and an introduction into Grails\n\n- and finally we&amp;#x2019;re going to create an app!\n\n
  • What are we&amp;#x2019;re doing to this afternoon?\n\n- First a little bit about myself\n\n- Grails TV, what is exactly Grails TV?\n\n- introduction into Groovy\n\n- and an introduction into Grails\n\n- and finally we&amp;#x2019;re going to create an app!\n\n
  • \n\nIt started all with this Commodore VIC-20 back in the 80&amp;#x2019;s.. Started hacking some small programs...and I learned different programming languages : Basic, Pascal, Modula, Delphi, Java...and in the end Groovy &amp; Grails\n\n
  • My first project with Grails &amp; Groovy : Fast Food Friday. The company I work for, we have a Fast Food Friday\nBut ordering the food was always a problem! So this was a great oppertunity to create my first Grails application : Fast Food Manager (or in dutch Vettebek Manager)\n
  • The last two years, I&amp;#x2019;m also giving presentation about Grails &amp; Groovy.. Last year I started HTML5 User Group, organized a HTML5 Hackathon, and HTML5 workshop for scholers!\n
  • The last two years, I&amp;#x2019;m also giving presentation about Grails &amp; Groovy.. Last year I started HTML5 User Group, organized a HTML5 Hackathon, and HTML5 workshop for scholers!\n
  • \n
  • Google TV .... a new experience that combines TV, the entire web, and apps...very cool... introduced last year\nbut when will it arrive?\n\ni\n
  • So... let&amp;#x2019;s not wait for Google ... just create it do day!\n\nLet&amp;#x2019;s build it with GRAILS... Grails is a dynamic web framework based on the language Groovy\n\nSo first we dive into Groovy.\n\n
  • Groovy is a popular dynamic language for the Java Virtual Machine. It&amp;#x2019;s inspired by languages like Python, Ruby and Smalltalk.\n\nIt makes modern programming features available to Java developers. \nFeatures like closures, dynamic methods. It supports Domain Specifice Languages and it simplifies testing.\n
  • Is there someone who can read this slide? Doesn&amp;#x2019;t matter.. \n\nAll this code is needed for reading a file and output it line by line\n\nThere is a better solution:\n
  • In Groovy all you need is this\n
  • Every modern language nowadays has the construct of a closure, like Javascript, Scala, Python.etc... but not Java... and it will be question if it ever will come..\n\nBut a closure is very neat\n
  • A closure is just a block of code .\n\n\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • class Dog {\n def bark() { println &quot;woof!&quot; }\n def sit() { println &quot;(sitting)&quot; }\n def jump() { println &quot;boing!&quot; }\n}\n\ndef doAction( animal, action ) {\n animal.&quot;$action&quot;() //action name is passed at invocation\n}\n\ndef rex = new Dog()\n\ndoAction( rex, &quot;bark&quot; ) //prints &apos;woof!&apos;\ndoAction( rex, &quot;jump&quot; ) //prints &apos;boing!&apos;\n\n\ndef builder = new groovy.xml.MarkupBuilder()\nbuilder.&apos;web-app&apos; {\n &apos;display-name&apos; &apos;My Web Application&apos;\n}\n\n
  • class Dog {\n def bark() { println &quot;woof!&quot; }\n def sit() { println &quot;(sitting)&quot; }\n def jump() { println &quot;boing!&quot; }\n}\n\ndef doAction( animal, action ) {\n animal.&quot;$action&quot;() //action name is passed at invocation\n}\n\ndef rex = new Dog()\n\ndoAction( rex, &quot;bark&quot; ) //prints &apos;woof!&apos;\ndoAction( rex, &quot;jump&quot; ) //prints &apos;boing!&apos;\n\n\ndef builder = new groovy.xml.MarkupBuilder()\nbuilder.&apos;web-app&apos; {\n &apos;display-name&apos; &apos;My Web Application&apos;\n}\n\n
  • Grails is a next-generation Java web development framework that generates great developer productivity gains through the confluence of a dynamic language\n
  • 2005 Ruby on Rails is all the rage these days, but compromise on your past investment..\n\n\nCan&amp;#x2019;t we leverage Groovy and proven technologies like Spring and Hibernate to bring the &amp;#x201C;Convention over Configuration&amp;#x201D; paradigm on the Java platform, without compromising on your investment?&amp;#x201D;\n\nConvention over Configuration\nScaffolding\nCode Templates\neasy database configuration\n
  • but the main goal : simplify the life of developers\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Spring : IoC, DI, Spring MVC, Spring Webflow\nHibernate : Object-Relational Mapping\nTomcat : application server\n\n
  • Spring : IoC, DI, Spring MVC, Spring Webflow\nHibernate : Object-Relational Mapping\nTomcat : application server\n\n
  • Spring : IoC, DI, Spring MVC, Spring Webflow\nHibernate : Object-Relational Mapping\nTomcat : application server\n\n
  • Spring : IoC, DI, Spring MVC, Spring Webflow\nHibernate : Object-Relational Mapping\nTomcat : application server\n\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Known as domain classes in Grails, represent the problem domain\n
  • \n
  • \n
  • \n
  • your domain model is a set of POGO&amp;#x2019;s\n\nyour domain class are transparentely mapped to the datase\n\nHibernate under the hood\n
  • \n
  • \n
  • \n
  • \n
  • control request flow, interact with models and delegate to views\n
  • - controllers return a Map as models for the view to render\n\n- easy databinding from from fields\n
  • - controllers return a Maps as models for the view to render\n\n- easy databinding from from fields\n
  • are defined in Groovy Server Pages to render the model\n
  • \n
  • \n
  • \n
  • - controllers return a Maps as models for the view to render\n\n- easy databinding from from fields\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript of "Grails TV : an introduction into Grails & Groovy"

    1. 1. Grails & Groovy introducing Grails TV Take the tour
    2. 2. To do A little about myself Grails TV Groovy Grails grails create-app
    3. 3. To do A little about myself Grails TV Groovy Grails grails create-app
    4. 4. To do A little about myself Grails TV Groovy Grails grails create-app
    5. 5. To do A little about myself Grails TV Groovy Grails grails create-app
    6. 6. To do A little about myself Grails TV Groovy Grails grails create-app
    7. 7. Fast Food Friday
    8. 8. http://www.ihenk.com @henkjurrienshenk.jurriens@gmail.com
    9. 9. 01 1? LL 2FA
    10. 10. Groovy
    11. 11. package com.groovy.home;import java.io.BufferedReader;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.IOException;public class TestFile {public static void main(String[] args){ BufferedReader br=null; try{ br=new BufferedReader(new FileReader("test.txt")); String line=null; while((line=br.readLine())!=null){ System.out.println(line); } } catch(FileNotFoundException e){ e.printStackTrace(); } catch(IOException e) { e.printStackTrace(); } }}
    12. 12. new File("test.txt").eachLine{ line -> println line}
    13. 13. Closures
    14. 14. def x = 2def c = { numberToSquare -> numberToSquare * numberToSquere}def y = c(x)
    15. 15. Collections
    16. 16. Listsdef list = [ 5, 6, 7, 8 ]list.each{ println it}
    17. 17. Mapsdef map = [ name: “henk” , likes : “cheese” ]assert map.get(“name”) == “henk”
    18. 18. • find• findAll• sort• sum
    19. 19. otherfeatures
    20. 20. Dynamic Methods
    21. 21. class Dog { def bark() { println "woof!" } def sit() { println "(sitting)" } def jump() { println "boing!" }}def doAction( animal, action ) { Dynamic Methods animal."$action"()}def rex = new Dog()doAction( rex, "bark" )
    22. 22. XMLBuilders
    23. 23. def builder = newgroovy.xml.MarkupBuilder()builder.web-app { XMLBuilders display-name My Web Application}
    24. 24. Convention over Configuration
    25. 25. Simplify the life of developers
    26. 26. =
    27. 27. =
    28. 28. =+
    29. 29. =+
    30. 30. =++
    31. 31. =++
    32. 32. Spring
    33. 33. SpringHibernate
    34. 34. SpringHibernateSiteMesh
    35. 35. SpringHibernateSiteMeshTomcat
    36. 36. Grails Stack Java Virtual Machine
    37. 37. Grails StackJava Language Java Virtual Machine
    38. 38. Grails Stack Java Development KitJava Language (JDK) Java Virtual Machine
    39. 39. Grails StackJava Enterprise Edition (JEE) Java Development Kit Java Language (JDK) Java Virtual Machine
    40. 40. Grails StackJava Enterprise Spring Edition (JEE) Java Development Kit Java Language (JDK) Java Virtual Machine
    41. 41. Grails StackJava Enterprise Spring Hibernate Edition (JEE) Java Development Kit Java Language (JDK) Java Virtual Machine
    42. 42. Grails StackJava Enterprise Spring Hibernate SiteMesh Edition (JEE) Java Development Kit Java Language (JDK) Java Virtual Machine
    43. 43. Grails StackJava Enterprise Spring Hibernate SiteMesh Groovy Edition (JEE) Java Development Kit Java Language (JDK) Java Virtual Machine
    44. 44. Grails Stack GrailsJava Enterprise Spring Hibernate SiteMesh Groovy Edition (JEE) Java Development Kit Java Language (JDK) Java Virtual Machine
    45. 45. grails create-app gtv
    46. 46. grails-app domain controllers views services taglib i18n
    47. 47. Wait!
    48. 48. Wait!Configuration files?
    49. 49. Wait! Configuration files?no database to configure?
    50. 50. Wait! Configuration files?no database to configure? no app server to install?
    51. 51. Models
    52. 52. class Movie { String title String description String image Integer rating String movie}
    53. 53. static constraints = { title(blank:false) description(size:10..200) rating(min:1, max:5)}
    54. 54. • blank • inList• email • nullable• url • min• range • scale
    55. 55. GORM
    56. 56. • Movie.count() • Movie.save()• Movie.list() • Movie.delete()• Movie.get(id) • etc
    57. 57. Querying
    58. 58. • find • countBy• findAllBy • list• count • listOrderby
    59. 59. def m = Movie.findByTitle(‘Star trek’)m = Movie.findByRating(4)m = Movie. findByReleaseDateBetween(..,..)
    60. 60. Controllers
    61. 61. http://srvr:8080/app/controller/action
    62. 62. Movie.properties = params
    63. 63. Views
    64. 64. Groovy Server Pages
    65. 65. Groovy Server Pages Grails Tag Libs
    66. 66. Groovy Server Pages Grails Tag LibsTemplates, URL mapping
    67. 67. <g:render template="menu"/><g:each in="${content}" var="item"><g:link action="detail" id="${item.id}" > </g:link> <h2>${item.title}</h2></g:each>
    68. 68. Plugins
    69. 69. > 500 plugins
    70. 70. > 500 plugins Security &authentication
    71. 71. > 500 plugins Security &authentication Scheduling
    72. 72. > 500 plugins Security &authentication jQuery Scheduling
    73. 73. > 500 plugins Security &authentication jQuery Scheduling Google App Engine
    74. 74. > 500 plugins Security &authentication jQuery Scheduling CouchDB Google App Engine
    75. 75. Let’s build GTV!
    76. 76. http://www.grails.orghttp://groovy.codehaus.org/
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×