• Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
812
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
20
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Introduction to Grails James Williams
  • 2. Introduction
    • James Williams
    • Groovy committer
    • Author of Google charts plugin
    • Griffon co-creator
    • Creator of SwingXBuilder
  • 3. Agenda
    • What is Grails?
    • Domain Classes
    • Controllers
    • GSP/Taglibs
    • Plugins
    • Web Services
    • Conclusion
  • 4. What is Grails?
    • Rapid web application development
    • Full-stack MVC framework
    • Open source
    • Runs on the JVM
  • 5. What is Grails? (cont'd)
    • Integrates best of breed tools...
    • And many more...
  • 6. Grails Quickstart
    • Install Grails
    • Run grails create-app <name>
    • Run grails run-app
  • 7. 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
  • 8. Constraints
    • Determine the validity of member fields
    • blank
    • creditCard
    • email
    • inList
    • matches
    • max
    • maxSize
    • min
    • minSize
    • notEqual
    • nullable
    • range
    • scale
    • size
    • unique
    • url
    • validator
  • 9. 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
    • ....
  • 10. Relationships
    • One to one
    • One to many (hasMany)
    • Many to many
  • 11. Demo
    • Domain Classes Demo
  • 12. 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
  • 13. 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
  • 14. Typical GSP
    • <html>
    • <body>
    • <% [1,2,3,4].each { num -> %>
    • <p><%=&quot;Hello ${num}!&quot; %></p>
    • <%}%>
    • </body>
    • </html>
  • 15. 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)
  • 16. Taglibs in the wild
    • <html>
      • <body>
        • <g:emoticon happy='true'>
      • </body>
    • </html>
  • 17. Demo
    • Controllers and GSP Demo
  • 18. 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;
        • }
    • }
  • 19. 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
  • 20. 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
  • 21. Demo
    • Plugins and Web services Demo
  • 22. Resources
    • Websites
      • grails.org
      • grailspodcast.com
      • groovyblogs.com
    • Books
  • 23. Questions?
    • Contact me
    • http://jameswilliams.be/blog
    • @ecspike