SVCC Intro to Grails
Upcoming SlideShare
Loading in...5
×
 

SVCC Intro to Grails

on

  • 1,523 views

Given at Silicon Valley Code Camp

Given at Silicon Valley Code Camp

Statistics

Views

Total Views
1,523
Views on SlideShare
1,521
Embed Views
2

Actions

Likes
1
Downloads
20
Comments
0

1 Embed 2

http://www.linkedin.com 2

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

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

SVCC Intro to Grails SVCC Intro to Grails Presentation Transcript

  • Introduction to Grails James Williams
  • Introduction
    • James Williams
    • Groovy committer
    • Author of Google charts plugin
    • Griffon co-creator
    • Creator of SwingXBuilder
  • Agenda
    • What is Grails?
    • Domain Classes
    • Controllers
    • GSP/Taglibs
    • Plugins
    • Web Services
    • Conclusion
  • What is Grails?
    • Rapid web application development
    • Full-stack MVC framework
    • Open source
    • Runs on the JVM
  • What is Grails? (cont'd)
    • Integrates best of breed tools...
    • And many more...
  • Grails Quickstart
    • Install Grails
    • Run grails create-app <name>
    • Run grails run-app
  • Domain Classes
    • Core objects that make up a Grails app
    • Are seamlessly persisted to storage
    • Can have constraints on values
    • Can have relationships with other domain classes
  • Constraints
    • Determine the validity of member fields
    • blank
    • creditCard
    • email
    • inList
    • matches
    • max
    • maxSize
    • min
    • minSize
    • notEqual
    • nullable
    • range
    • scale
    • size
    • unique
    • url
    • validator
  • Grails ORM (GORM)
    • No hassle database persistence
    • Leverages Hibernate but minus .hbm files and other messy configuration files
    • Provides dynamic domain class methods like...
    • create
    • save
    • delete
    • update
    • get
    • find
    • findAll
    • addTo
    • count
    • ....
  • Relationships
    • One to one
    • One to many (hasMany)
    • Many to many
  • Demo
    • Domain Classes Demo
  • Controllers
    • Manages requests and response for domain objects
    • Unless overridden, maps requests to a REST-like structure /<domain class>/action_name
    • It's actions can be generated on the fly by the application
  • Groovy Server Pages
    • Provide views for domain objects
    • Like JSP, GSPs can be a mix of markup, Groovy code and GSP tags*
    • Generally correspond to an associated action in the controller
    • Code fragments use the <% %> and <%= %> forms, though this is discouraged
  • Typical GSP
    • <html>
    • <body>
    • <% [1,2,3,4].each { num -> %>
    • <p><%=&quot;Hello ${num}!&quot; %></p>
    • <%}%>
    • </body>
    • </html>
  • Taglibs
    • Allow the developer to simplify blocks of code
    • Similar to JSP tag libs class SimpleTagLib { def emoticon = { attrs, body -> out << body() << attrs.happy == 'true' ? &quot; :-)&quot; : &quot; :-(&quot; } }
    • Can be declared at an application or plugin level (e.g. Grails Chart plugin)
  • Taglibs in the wild
    • <html>
      • <body>
        • <g:emoticon happy='true'>
      • </body>
    • </html>
  • Demo
    • Controllers and GSP Demo
  • Databases
    • Grails supports almost all JDBC compliant databases
    • grails-app/conf/Datasources.groovy allows you to specify datasources for different env's
    • environments {
      • development {
        • dataSource {
          • dbCreate = &quot;update&quot;
          • url = &quot;jdbc:hsqldb:mem:devDB&quot;
          • pooled = true
          • driverClassName = &quot;org.hsqldb.jdbcDriver&quot;
          • username = &quot;sa&quot;
          • password = &quot;&quot;
        • }
    • }
  • Plugins
    • Grails applications in and of themselves
    • Can
      • provide shortcuts to core tasks
      • encapsulate and integrate external tools
    • Benefit from the huge library of J2EE tools and libraries
    • Over 50 hosted at grails.org
  • Web Services
    • REST
    • SOAP (requires XFire plugin) class BookService {
      • static expose=['xfire']
      • Book[] getBooks(){ Book.list() as Book[] }
    • }
    • XML Marshaling as XML
    • JSON Marshaling as JSON
  • Demo
    • Plugins and Web services Demo
  • Resources
    • Websites
      • grails.org
      • grailspodcast.com
      • groovyblogs.com
    • Books
  • Questions?
    • Contact me
    • http://jameswilliams.be/blog
    • @ecspike