• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Grails TV : an introduction into Grails & Groovy
 

Grails TV : an introduction into Grails & Groovy

on

  • 1,877 views

An introduction into Grails & Groovy

An introduction into Grails & Groovy

Statistics

Views

Total Views
1,877
Views on SlideShare
1,876
Embed Views
1

Actions

Likes
2
Downloads
33
Comments
0

1 Embed 1

http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Hello everybody, today I’m to going explain Grails & Groovy by introducing Grails\n\n\n
  • What are we’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’re going to create an app!\n\n
  • What are we’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’re going to create an app!\n\n
  • What are we’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’re going to create an app!\n\n
  • What are we’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’re going to create an app!\n\n
  • \n\nIt started all with this Commodore VIC-20 back in the 80’s.. Started hacking some small programs...and I learned different programming languages : Basic, Pascal, Modula, Delphi, Java...and in the end Groovy & Grails\n\n
  • My first project with Grails & 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’m also giving presentation about Grails & Groovy.. Last year I started HTML5 User Group, organized a HTML5 Hackathon, and HTML5 workshop for scholers!\n
  • The last two years, I’m also giving presentation about Grails & 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’s not wait for Google ... just create it do day!\n\nLet’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’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’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 "woof!" }\n def sit() { println "(sitting)" }\n def jump() { println "boing!" }\n}\n\ndef doAction( animal, action ) {\n animal."$action"() //action name is passed at invocation\n}\n\ndef rex = new Dog()\n\ndoAction( rex, "bark" ) //prints 'woof!'\ndoAction( rex, "jump" ) //prints 'boing!'\n\n\ndef builder = new groovy.xml.MarkupBuilder()\nbuilder.'web-app' {\n 'display-name' 'My Web Application'\n}\n\n
  • class Dog {\n def bark() { println "woof!" }\n def sit() { println "(sitting)" }\n def jump() { println "boing!" }\n}\n\ndef doAction( animal, action ) {\n animal."$action"() //action name is passed at invocation\n}\n\ndef rex = new Dog()\n\ndoAction( rex, "bark" ) //prints 'woof!'\ndoAction( rex, "jump" ) //prints 'boing!'\n\n\ndef builder = new groovy.xml.MarkupBuilder()\nbuilder.'web-app' {\n 'display-name' 'My Web Application'\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’t we leverage Groovy and proven technologies like Spring and Hibernate to bring the “Convention over Configuration” paradigm on the Java platform, without compromising on your investment?”\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’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

Grails TV : an introduction into Grails & Groovy Grails TV : an introduction into Grails & Groovy Presentation Transcript

  • 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;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(); } }}
  • 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 doAction( animal, action ) { Dynamic Methods animal."$action"()}def rex = new Dog()doAction( rex, "bark" )
  • XMLBuilders
  • def builder = newgroovy.xml.MarkupBuilder()builder.web-app { XMLBuilders display-name My Web Application}
  • 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) Java Virtual Machine
  • Grails StackJava Enterprise Edition (JEE) Java Development Kit Java Language (JDK) Java Virtual Machine
  • Grails StackJava Enterprise Spring Edition (JEE) Java Development Kit Java Language (JDK) Java Virtual Machine
  • Grails StackJava Enterprise Spring Hibernate Edition (JEE) Java Development Kit Java Language (JDK) Java Virtual Machine
  • Grails StackJava Enterprise Spring Hibernate SiteMesh Edition (JEE) Java Development Kit Java Language (JDK) Java Virtual Machine
  • Grails StackJava Enterprise Spring Hibernate SiteMesh Groovy Edition (JEE) Java Development Kit Java Language (JDK) Java Virtual Machine
  • Grails Stack GrailsJava Enterprise Spring Hibernate SiteMesh Groovy Edition (JEE) Java Development Kit Java Language (JDK) Java Virtual Machine
  • 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> <h2>${item.title}</h2></g:each>
  • 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 Google App Engine
  • Let’s build GTV!
  • http://www.grails.orghttp://groovy.codehaus.org/