Java Users Group Charleston, SC June 25, 2008 Introduction to Grails by Jason McDonald.

Slides:



Advertisements
Similar presentations
May 13th, Lucek Consulting Basic Java Servlet/JSP Web Development David Lucek Lucek Consulting
Advertisements

.NET 3.5 SP1 New features Enhancements Visual Studio 2008 SP1 New features Enhancements Additional features/enhancements.
Java Script Session1 INTRODUCTION.
The Librarian Web Page Carol Wolf CS396X. Create new controller  To create a new controller that can manage more than just books, type ruby script/generate.
Apache Struts Technology
1.  Understanding about How to Working with Server Side Scripting using PHP Framework (CodeIgniter) 2.
Creating Web Services with Ruby on Rails Robert Thew Internet and Web Systems II.
Presented by: Stirling Crow and Jason Foutz University of New Mexico June 5th, 2014 Creating a Stand-alone GRAILS Application Getting ready for Banner.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
Copyright Dr Peter Lappo Copy only with credits. 1 Building an Online Conference Booking Programme with Grails In an Hour !
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
Groovy & Grails Jean Barmash CTO, EnergyScoreCards.com
Apache Struts Technology A MVC Framework for Java Web Applications.
Web Applications Basics. Introduction to Web Web features Clent/Server HTTP HyperText Markup Language URL addresses Web server - a computer program that.
Introduction to Java web programming Dr Jim Briggs JWP intro1.
Web 2.0 with AJAX Students : LASC Ioana KELEMEN Csilla POP Dan Adrian CIOBANU Dumitru Daniel Project leader : Ahmed RHIAT.
© Internna Technologies 1 IWebMvc Features, Possibilities & Goals.
UNIT-V The MVC architecture and Struts Framework.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
NextGen Technology upgrade – Synerizip - Sandeep Kamble.
Rails and Grails. To get started Make sure you have java installed You can get the sdk and jre at:
JSP Standard Tag Library
AJAX Chat Analysis and Design Rui Zhao CS SPG UCCS.
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
Tomcat Spencer Uresk. Notes This is a training NOT a presentation Please ask questions This is being recorded
Groovy in 15 minutes… Johannes Carlén Callista Enterprise AB
Guidelines for Homework 6. Getting Started Homework 6 requires that you complete Homework 5. –All of HW5 must run on the GridFarm. –HW6 may run elsewhere.
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
Chapter 8 Script-free pages. Problem with scripting in JSP When you use scripting (declaration, scriplet, expressions) in your JSP, you actually put Java.
An Introduction To Building Groovy Web Applications With Grails Jeff Brown – Principal Software Engineer Object Computing Inc.
Standalone Java Application vs. Java Web Application
1 Groovy for Java developers and testers How Java developers and testers could use Groovy to increase their efficiency AUGUST 6, 2015.
Tom Castiglia Hershey Technologies
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
Chapter 8 Cookies And Security JavaScript, Third Edition.
By: Saurabh Dixit.  Groovy server pages  Taglibs  Validators in grails.
JAVA SERVER PAGES CREATING DYNAMIC WEB PAGES USING JAVA James Faeldon CS 119 Enterprise Systems Programming.
Grails Mansura Habiba 13 november Introduction What is Grails? Runs on the Java Virtual Machine Used Java like dynamic language Groovy Inspired.
Lap Around Visual Studio 2008 &.NET 3.5 Enhancements.
JSTL Lec Umair©2006, All rights reserved JSTL (ni) Acronym of  JavaServer Pages Standard Tag Library JSTL (like JSP) is a specification, not an.
2006 JavaOne SM Conference | Session BOF-2521 | Rapid Web Application Development with Grails Graeme Rocher Managing Director Agilize it
Chính phủ điện tử TS. Phạm Văn Tính Khoa CNTT, ĐH Nông Lâm TP.HCM
INTEGRATION OF BACKBONE.JS WITH SPRING 3.1. Agenda New Features and Enhancements in Spring 3.1 What is Backbone.js and why I should use it Spring 3.1.
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
An Introduction to JavaServer™ Pages Prepared by Nicole Swan.
JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
Implementation Struts Framework for well-architectured web applications Model-View-Controller design pattern.
CSI 3125, Preliminaries, page 1 JSP (Java Server Pages)
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
Ruby on Rails. Web Framework for Ruby Designed to make it easier to develop, deploy, and maintain web applications Design with Model-View-Controller –almost.
Apache Struts Technology A MVC Framework for Java Web Applications.
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
CS520 Web Programming Spring – Web MVC Chengyu Sun California State University, Los Angeles.
Web Routing Designing an Interface
Internationalization
Google Web Toolkit Tutorial
Play Framework: Introduction
Scripted Page Web App Development (Java Server Pages)
PHP Training at GoLogica in Bangalore
Knowledge Byte In this section, you will learn about:
Introduction to Grails
Introduction to JBoss application server
ESIS Consulting LLC (C) ESIS Consulting LLC. All rights reserved
Presentation transcript:

Java Users Group Charleston, SC June 25, 2008 Introduction to Grails by Jason McDonald

Getting Started

Grails Basics Open Source Fully integrated with Java Groovy based – Uses ANTLR to compile Groovy down to JVM compatible bytecode Predicated on DRY principle

Underlying Technologies Spring Hibernate Log4J Junit Quartz Ant

Native Support HSQL MySQL Servlet container servers – Jetty – Tomcat AJAX and DHTML – Dojo – Prototype – Yahoo!

Installation Visit Download and extract files Create GRAILS_HOME environment variable Add %GRAILS_HOME% to PATH environment variable That’s it!

Grails Structure

Goovy Roots Built on top of Java Very similar syntax to java Supports closures Method returns can be slightly different Case sensitive No semi-colons needed All classes end in.groovy

Conditional Environments Environment conditionals allow for variations for a specific environment – Database – Initialization options – More Three environment choices – Development – Testing – Production

Script Based Code Generation grails create-app [app name] grails create-controller [controller name] grails create-domain-class [class name] grails create-service [service name] grails create-unit-test [test name] grails create-tag-lib [taglib name] grails generate-all [class name] grails generate-views [class name]

Building, Deploying, and Managing grails clean grails compile grails console grails doc grails install-plugin grails run-app grails war

Important Files conf/DataSource.groovy – Database connections conf/UrlMapping.groovy – Routing conf/BootStrap.groovy – Bootstrap file conf/Config.groovy – Configurations (MIME mappings, more…)

Routing Route rules found in conf/UrlMapping.groovy Default route: – application/controller/action/id[?params] Additional rules and restrictions can be applied here static mappings = { "/product/$id?"(controller:"product"){ action = [GET:"show", PUT:"update", DELETE:"delete", POST:"save"] } }

Databases db configuration is in conf/DataSource.groovy Can define at environment level or global level Defaults to HSQL Change to MySQL by: – Dropping MySQL connector in the lib – Changing DataSource.groovy to point at MySQL

Database Create Scheme dbCreate – create-drop: creates tables on startup and drops them on shutdown (DEV) – create: creates tables on startup, deletes data on shutdown (DEV, TEST) – update – creates tables on startup, saves data between restarts (TEST, PROD)

Grails MVC

MVC Framework Standard MVC implementation Sits on top of Spring MVC – Reduces repetition of XML developers must maintain – Gives access to Spring DSL

Views Groovy Server Pages – GSP extension – Based on JSP pages – Use Tag libraries Expressions – similar to JSP EL but allows any expression within ${…}

Tag Libraries Ordering and sorting Form display... Formatting

Custom Tag Libraries Custom tag libraries are just groovy classes that end with TagLib Defaults to ‘g’ namespaces unless declared Closure defines actual tag: class FormattingTagLib { static namespace = ‘fmt’ def dateFormat = { attrs -> out

Internationalization Support Based on Java i18n specifications Define properties files with language specific entries Views can read i18n entries with a tag: Tag libraries can read entries with code: g.message(code: ‘my.message’, args: [‘One’, ‘Two’])

Models POGOs – Fields default to private – Getters and setters provided automatically – Must use wrapper objects – no primitives (1.5?) – Field validation defined within: static constraints = { date(nullable: false) } Can define custom messages using convention: – className.propertyName.constraint = ‘’Err msg’’ – Automatic parameter mapping from view book.properties = params

GORM Grails Object Relational Mapping Uses Hibernate3 Dynamic methods for finding Book.findByTitle(“The Dark Tower“) Book.findByTitleAndAuthor(“The Dark Tower”, “Stephen King” Book.findByTitle(“Christine”, [sort: ‘edition’, order: ‘asc’] ) Relational mapping defined within – One to many: static hasMany = [ attendances:Attendance ] – One to one: Attendance attendance

GORM Caching Provides the same caching mechanisms that can be found with Hibernate3 Updates to DataSource.groovy can toggle caching: hibernate { cache.use_second_level_cache = true cache.use_query_cache = true cache.provider_class = ‘org.hibernate.cache.EhCacheProvider’ }

Controllers House actions (methods) that respond to a request Actions should map to GSP of same name index is the default action Can define the method each action is allowed: def allowedMethods = [save:'POST', update:'POST'] – GET is the default Auto scaffolding sets up CRUD without files def scaffold = true // In Controller class

Action Responses All actions respond in one of three ways: – redirect Equivalent ot response.sendRedirect Can specify actions, controller, params, and more – return Returns a value and calls a GSP of the same name (action method ‘go’ will forward to go.gsp) – render Calls a GSP by name Has the ability to pass arguments

Grails in Action

Web Services REST – Provide RESTful mappings in UrlMappings.groovy – Implement controller to accept and return marshalled data SOAP – Supported through XFire plug-in – Simply expose a service: static expose = [‘xfire’]

Testing Test framework based on JUnit Unit tests – By convention uses mock objects Integration tests – By convention use real objects Functional tests – Supports Canoo WebTest integration

Running the Application Bootstrapping data – Allows for initialization and test data Jetty Server – Specify port and environment on command line grails dev –Dserver.port=9999 run-app Tomcat – As war – Exploded

The Example

Requirements Application needs to: – Store meetings, people, and which meetings each person attends People should store first and last name Meetings should store date and subject of meeting – Must have full CRUD capability – Must be web based – Must be able to integrate with Java environments (to meet future integration needs)

Open Discussion