• Save
Grails Workshop - Dallas TechFest 2011
Upcoming SlideShare
Loading in...5
×
 

Grails Workshop - Dallas TechFest 2011

on

  • 4,051 views

This is the two-part presentation I gave at Dallas TechFest 2011. This hands-on workshop was geared for people new to the Grails framework. By the end of the second session attendees had built a ...

This is the two-part presentation I gave at Dallas TechFest 2011. This hands-on workshop was geared for people new to the Grails framework. By the end of the second session attendees had built a working web application that could replace the website used to power Dallas Techfest.

Statistics

Views

Total Views
4,051
Slideshare-icon Views on SlideShare
2,266
Embed Views
1,785

Actions

Likes
0
Downloads
0
Comments
0

11 Embeds 1,785

http://erik.weibust.net 1736
http://localhost 20
http://www.linkedin.com 9
http://twitter.com 8
http://www.365dailyjournal.com 2
http://ranksit.com 2
http://prlog.ru 2
http://search.daum.net 2
http://www.weibust.net 2
http://www.erik.weibust.net 1
http://webcache-exp-test.googleusercontent.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

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

    Grails Workshop - Dallas TechFest 2011 Grails Workshop - Dallas TechFest 2011 Presentation Transcript

    • THE POWER OF PERSPECTIVE Grails Workshop Dallas TechFest 2011 August 13, 2011 Erik Weibust @erikweibust Copyright © 2011 Credera. All Rights Reserved.
    • www.credera.com Who am I? Erik Weibust…  Husband / Father  Fightin’ Texas Aggie  Sports Fan  Blogger  Twiter-er… tweeter?  Fan of Java and the JVM (Evangelist) – President of JavaMUG – Founder of the Spring Dallas Users Group (SDUG) – Co-Founder of the DFW Groovy – Grails Users Group (DFW2GUG)  Senior Architect at Credera – 14 years experience as an IT Professional – 12 years experience with Java – Last 4 years at CrederaCopyright © 2011 Credera. -2- All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com About Erik Weibust: Husband, Father, and Fightin’ Texas AggieCopyright © 2011 Credera. -3- All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com About Erik Weibust: Sports Fan  Text HeeCopyright © 2011 Credera. -4- All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com About Erik Weibust: Blogger / Twitter-erCopyright © 2011 Credera. -5- All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com About Erik Weibust: Spring Dallas UG, DFW 2GUG, JavaMUG President  Text HereCopyright © 2011 Credera. -6- All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com About Erik Weibust: Senior Architect at CrederaCopyright © 2011 Credera. -7- All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Agenda  What is Grails and why would I use it  Installing and Developing with Grails  Wait a minute, what is Groovy  What are we Building?  Creating our Grails Application – Step 1 We’ve Got a Lot to Do… Let’s Get Started!  Creating our Domain Model – Step 2  We need Data – Step 3  Lets tweak these boring Views – Step 4  Are you too good for your Home – Step 5  Custom URL Mappings – Step 6Copyright © 2011 Credera. -8- All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com What is Grails and why would I use it  Rapid Application Development Framework  Tightly bound to Java Ecosystem (can be both positive and negative)  Built on top of frameworks you know and use: Spring, Spring MVC, Hibernate, and Tomcat  Convention over Configuration  Makes web development simpler with GroovyCopyright © 2011 Credera. -9- All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Installing and Developing with Grails  Install Java5 SE SDK and set JAVA_HOME environment variable  Download latest Grails release (http://grails.org/Download)  Extract Grails archive into appropriate location (I use C:devsdks)  Create GRAILS_HOME env variable that points to location in previous step  Append %GRAILS_HOME%bin to your PATH variableCopyright © 2011 Credera. - 10 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Wait a minute, what is Groovy  Programming lang on JVM  Highly compatible with Java – Seriously, rename .java file with .groovy and you’re done – Optional semicolons – Sometimes optional parentheses (I always use, makes code more readable) – “Look Ma, no returns”  Properties and it’s “cousin feature” named-argument constructors  Simple debugging when learning: println and thingy.class.name  Lists, Maps, and ClosuresCopyright © 2011 Credera. - 11 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Domain Class in Java: Person.javaCopyright © 2011 Credera. - 12 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Same Domain Class in Groovy: Person.groovy Look at this Person class … Just 3 lines of code! Previous slide shows same class in Java took 26 lines!Copyright © 2011 Credera. - 13 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com The Kitchen Sink of Groovy “stuff”Copyright © 2011 Credera. - 14 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com What are we Building? A Web-based Conference Management Tool  Grails-based version of TechFest website – Runs on open-source technology – Fixes the many to many Speaker – Session relationshipCopyright © 2011 Credera. - 15 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Dallas TechFest Domain ModelCopyright © 2011 Credera. - 16 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Creating our Grails Application – Step 1  Create with the following command:  $ grails create-app techfest  We have a working, runnable application…  Lets take a look, run the following commands:  $ cd techfest  $grails run-appCopyright © 2011 Credera. - 17 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Creating our Grails Application – Step 1 cont.  Here you can see the standard Grails project structure – Our application code is primarily inside of grails- app/ – Have a lib/ for application specific jar files (JDBC driver) – Testing is baked into Grails, we have unit and integration tests in test/ – All standard CSS, JavaScript and images are in web-app/Copyright © 2011 Credera. - 18 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Creating our Domain Model – Step 2  Create our domain classes with the following commands: – $ grails create-domain-class Speaker – $ grails create-domain-class Session – $ grails create-domain-class Sponsor Now implement our SpeakerCopyright © 2011 Credera. - 19 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Creating our Domain Model – Step 2 cont.  We also need to create our controllers so we can interact with our domain classes  Run the following commands: – $ grails create-controller Speaker – $ grails create-controller Session – $ grails create-controller Sponsor Now lets take a look at our Speaker!  Now edit each controller, replacing our index {} closure property with the Finished version of our Speaker Controller, following scaffolding statement: the other controllers should look the same – def scaffold = trueCopyright © 2011 Credera. - 20 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Creating our Domain Model – Step 2 cont.  Now we can finish our Speaker, adding the logical constraints  Highlights on Constraints: Fully implemented Speaker w/ constraints – Validation on Creation – Declarative syntax – DSLCopyright © 2011 Credera. - 21 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Creating our Domain Model – Step 2 cont.  Lets complete our Session and Sponsor Domain Model classes Our Sponsor Class And our Session ClassCopyright © 2011 Credera. - 22 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com We need Data – Step 3  OUCH! That was painful entering our “test” data each time we restarted our server…. BootStrap.groovy to the rescue.  Back to Scaffolding: – Lets convert from dynamic views and controllers to concrete implementations  $ grails generate-all “*” – Enter “Y” for yes, to overwrite our original files  Lets take a look…Copyright © 2011 Credera. - 23 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Lets tweak these boring Views – Step 4  Lets “clean up” our Speaker page: – Open grails- app/views/speaker/sh ow.gsp – Replace Show Speaker text with Speaker’s name – Remove the database id field from our view – Make the Speaker’s name link back to the Speaker record (make sure and ask me why)Copyright © 2011 Credera. - 24 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Lets tweak these boring Views – Step 4 cont.  Start by replacing the <h1> with our new <h1> that utilizes the ${fieldValue( bean:speakerInstance, field:”firstName” ) } syntax  Delete or comment-out the first three <tr>s to remove: id, firstName, and lastName  Add g:link to create a link back to our record  See Grails documentation for more info on <g:link> http://www.grails.org/doc/ latest/ref/Tags/link.htmlCopyright © 2011 Credera. - 25 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Are you too good for your Home – Step 5  First step is swapping out the Grails logo for the TechFest logo – Copy image file to web- app/images – Update grails- app/views/layouts/main .gspCopyright © 2011 Credera. - 26 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Are you too good for your Home – Step 5 cont.  Second step in refactoring our “home” page is updating grails- app/views/index.gsp – Make the following 2 CSS changes to move our nav bar to the right – Then add the “nav” <div> right after the <body> tag to get our navigation bar added to our “home” page  Last step is two pull in the two sponsor logos and the “copy” from our thumb drivesCopyright © 2011 Credera. - 27 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Custom URL Mappings – Step 6  Last “tweak” we will make to our techfest application is writing some custom URL mappings to match the URL patterns used on grails-app/conf/UrlMappings.groovy the http://dallastechfest.co m site  Make the following additions to our UrlMappings.groovy fileCopyright © 2011 Credera. - 28 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Finished: We have our TechFest website…Copyright © 2011 Credera. - 29 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Where to go for more information  Grails Website – Phenomenal Documentation – Screencasts – Tutorials  Books – Grails: A Quick-Start Guide by Dave Klein (http://pragprog.com/book/dkgrails/grails) – The Definitive Guide to Grails by Graeme Rocher, Jeff Brown (http://www.apress.com/9781590599952)  Magazine – GROOVYMAG (http://groovymag.com/)  DFW Groovy – Grails Users Group (http://www.dfw2gug.org or @dfw2gug)Copyright © 2011 Credera. - 30 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Credera is a Business and Technology Consulting Firm that Focuses on Leveraging Proven Technologies to Enable our Clients Business Strategy  Our Company  Our People – Full-service business and technology – Credera’s professionals possess a unique consulting firm combination of deep technical expertise with extensive business backgrounds – Provide business and technology solutions that offer measurable value to our clients – Backgrounds include business, technology, and strategy management consulting with some of the – Deliver value by leveraging our people’s most well-known and respected consulting firms accumulated industry and management in the world experience with their deep technical expertise – Have served many influential corporations in a variety of industries over the past 20 years – Established in 1999 – Offices in Dallas, Austin, Denver  Sample Clients  Our Services – Management Consulting – Technology Solutions – Business IntelligenceCopyright © 2011 Credera. - 31 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • www.credera.com Q&A Thank you for attending! Contact Information: Erik Weibust erik@weibust.net http://erik.weibust.net Twitter: @erikweibustCopyright © 2011 Credera. - 32 - All Rights Reserved. T H E P O W E R O F P E R S P E C T I V E
    • THE POWER OF PERSPECTIVE Grails Workshop Dallas TechFest 2011 August 13, 2011 Erik Weibust @erikweibust Copyright © 2011 Credera. All Rights Reserved.