Dynamic website development using the Grails Platform. Joshua Davis Senior Architect Cognizant Technology Solutions joshua.davis@cognizant.



Similar documents
Grails 1.1. Web Application. Development. Reclaiming Productivity for Faster. Java Web Development. Jon Dickinson PUBLISHING J MUMBAI BIRMINGHAM

Rapid Application Development. and Application Generation Tools. Walter Knesel

YouTrack MPS case study

Grails: Accelerating J2EE Application Development

A Comparison of Open Source Application Development Frameworks for the Enterprise

Web Frameworks. web development done right. Course of Web Technologies A.A. 2010/2011 Valerio Maggio, PhD Student Prof.

Agile Development with Groovy and Grails. Christopher M. Judd. President/Consultant Judd Solutions, LLC

Grails - Rapid Web Application Development for the Java Platform

Outline. Lecture 18: Ruby on Rails MVC. Introduction to Rails

White Paper On. Single Page Application. Presented by: Yatin Patel

JBoss Portal 2.4. Quickstart User Guide

EVALUATION ONLY. WA2088 WebSphere Application Server 8.5 Administration on Windows. Student Labs. Web Age Solutions Inc.

Business Application Development Platform

Intruduction to Groovy & Grails programming languages beyond Java

BEST WEB PROGRAMMING LANGUAGES TO LEARN ON YOUR OWN TIME

Ruby On Rails. CSCI 5449 Submitted by: Bhaskar Vaish

Esigate Module Documentation

The Learn-Verified Full Stack Web Development Program

IBM Digital Experience. Using Modern Web Development Tools and Technology with IBM Digital Experience

Advanced Service Design

Web Development Frameworks

Framework as a master tool in modern web development

Liferay Portal User Guide. Joseph Shum Alexander Chow

Ruby on Rails is a web application framework written in Ruby, a dynamically typed programming language The amazing productivity claims of Rails is

ORACLE APPLICATION EXPRESS 5.0

White Paper. Java versus Ruby Frameworks in Practice STATE OF THE ART SOFTWARE DEVELOPMENT 1

The Hitchhiker s Guide to Github: SAS Programming Goes Social Jiangtang Hu d-wise Technologies, Inc., Morrisville, NC

Dimension Technology Solutions Team 2

Customer Bank Account Management System Technical Specification Document

Eclipse Web Tools Platform. Naci Dai (Eteration), WTP JST Lead

MarkLogic Server. Reference Application Architecture Guide. MarkLogic 8 February, Copyright 2015 MarkLogic Corporation. All rights reserved.

Sisense. Product Highlights.

Start Learning Joomla!

PEGA MOBILITY A PEGA PLATFORM WHITEPAPER

MVC FRAMEWORK MOCK TEST MVC FRAMEWORK MOCK TEST II

Integrating your Maven Build and Tomcat Deployment

Specialized Programme on Web Application Development using Open Source Tools

An introduction to creating JSF applications in Rational Application Developer Version 8.0

CHOOSING THE RIGHT HTML5 FRAMEWORK To Build Your Mobile Web Application

Server-side OSGi with Apache Sling. Felix Meschberger Day Management AG 124

Citrix StoreFront. Customizing the Receiver for Web User Interface Citrix. All rights reserved.

Software Development Kit

Ruby on Rails. a high-productivity web application framework. blog.curthibbs.us/ Curt Hibbs <curt@hibbs.com>

Profiling and Testing with Test and Performance Tools Platform (TPTP)

This document gives an outline of Tim Ward s work on mobile phone systems

Modeling Web Applications Using Java And XML Related Technologies

tibbr Now, the Information Finds You.

AJAX Toolkit Framework

How To Understand The Architecture Of An Ulteo Virtual Desktop Server Farm

Decision Support System Software Asset Management (SAM)

Managed Devices - Web Browser/HiView

Developing ASP.NET MVC 4 Web Applications MOC 20486

10CS73:Web Programming

Evaluation. Chapter 1: An Overview Of Ruby Rails. Copy. 6) Static Pages Within a Rails Application

HPC Portal Development Platform with E-Business and HPC Portlets

Web Cloud Architecture

Rational Software White Paper

Actuate Business Intelligence and Reporting Tools (BIRT)

Build management & Continuous integration. with Maven & Hudson

Change Management for Rational DOORS User s Guide

Spectrum Technology Platform

Is Liferay Right for Your Organization? Seven Things to Consider When Choosing a Portal Platform

Introduction to Open Atrium s workflow

SOA REFERENCE ARCHITECTURE: WEB TIER

Database Migration Plugin - Reference Documentation

GUI and Web Programming

Framework Adoption for Java Enterprise Application Development

Web Made Easy. Planning Session

Category: Business Process and Integration Solution for Small Business and the Enterprise

SharePoint Integration Framework Developers Cookbook

Document Management. Document Management for the Agile Enterprise. AuraTech Pte Ltd

Document management and exchange system supporting education process

Introduction to CloudScript

Swirl. Multiplayer Gaming Simplified. CS4512 Systems Analysis and Design. Assignment Marque Browne Manuel Honegger

OUR COURSES 19 November All prices are per person in Swedish Krona. Solid Beans AB Kungsgatan Göteborg Sweden

How To Write A Web Framework In Java

CONNECTING TO DEPARTMENT OF COMPUTER SCIENCE SERVERS BOTH FROM ON AND OFF CAMPUS USING TUNNELING, PuTTY, AND VNC Client Utilities

Vector HelpDesk - Administrator s Guide

Continuous Integration

CTC What's New?

10 Game-changing Features in Visual Studio 2013 for the ASP.NET Developer

This manual cannot be redistributed without permission from joomla-monster.com

Elgg 1.8 Social Networking

Office 365 SharePoint Online White Paper

Portals and Hosted Files

Guiding Principles for Technical Architecture

Quick start. A project with SpagoBI 3.x

CHAPTER 1 - JAVA EE OVERVIEW FOR ADMINISTRATORS

WHITE PAPER. Peter Drucker. intentsoft.com 2014, Intentional Software Corporation

Developing Exceptional Mobile and Multi-Channel Applications using IBM Web Experience Factory

Case Study. Data Governance Portal Brainvire Infotech Pvt Ltd Page 1 of 1

Transcription:

Dynamic website development using the Grails Platform Joshua Davis Senior Architect Cognizant Technology Solutions joshua.davis@cognizant.com

Topics Covered What is Groovy? What is Grails? What are the Grails Principles? What can the Grails Portal do? Using the Grails Portal Framework? Grails Portal Visions for the future

What is Groovy? Is an agile and dynamic language for the Java Virtual Machine Builds upon the strengths of Java but has additional features. Makes modern programming features available to Java developers with almost-zero learning curve Supports Domain-Specific Languages and other compact syntax so your code becomes easy to read and maintain Makes writing shell and build scripts easy with its powerful processing primitives, OO abilities and an Ant DSL Increases developer productivity by reducing scaffolding code when developing web, GUI, database or console applications Simplifies testing by supporting unit testing and mocking out-of-thebox Seamlessly integrates with all existing Java objects and libraries Compiles straight to Java bytecode so you can use it anywhere you can use Java

What is Grails? A simplification of existing Java Web Application Frameworks. Embraces the Don't Repeat Yourself (DRY) principles. Originated from dynamic frameworks like Ruby on Rails and others. They have helped pave the way to a more modern way of thinking about web applications. Grails builds on these concepts and dramatically reduces the complexity of building web applications on the Java platform. Builds on already established Java technology like Spring & Hibernate.

What is Grails(continued)? Grails is a full stack framework and attempts to solve as many pieces of the web development puzzle through the core technology and it's associated plug-ins. Included out the box are things like: An easy to use Object Relational Mapping (ORM) layer built on Hibernate An expressive view technology called Groovy Server Pages (GSP) A controller layer built on Spring MVC A command line scripting environment built on the Groovy-powered Gant An embedded Tomcat container which is configured for on the fly reloading Dependency injection with the inbuilt Spring container Support for internationalization (i18n) built on Spring's core MessageSource concept A transactional service layer built on Spring's transaction abstraction All of these are made easy to use through the power of the Groovy language and the extensive use of Domain Specific Languages (DSLs)

What are the Grails Principles? DRY - Don't Repeat Yourself This principle is centered around the concept on a singular representation for everything in your application. The advantage of this is to lower the amount of maintenance needed and dramatically decrease complexity. Grails attempts to implement the DRY principle by having a well organized set of artifacts that the developer uses as well as using generators for source code. Convention over Configuration Design a framework so that it enforces standard naming conventions for mapping classes to resources or events. A programmer only needs to write the mapping configurations when the naming convention fails.

What Can the Grails Portal Do? Fundamental user-based set of functionality that can be used to write web applications that require users to be authorized and have personalization of presentation and functionality based upon the context of the logged in user.

Why a Grails Portal Most small web applications don t merit being created within a JSR- 168/286 portal environment. Fulfills the need for a rapid solution for allowing users to self-register and authenticate, and then manage the authorization of the user to specific functionality. Grails poses a very interesting choice for the class of database/model backed web-applications evidenced by it s Ability to incorporate new functionality quickly. Enabled by features and plug-ins for Grails. GSP templates Grails Object Relational Mapping (GORM) Web-Flow plug-in enables business processed based portal functionality to be quickly implemented. Grails UI plug-in enables Yahoo Ui Ajax functionality

Using the Grails Portal Framework

Developing with Grails What is recommended for Grails Development? Spring STS (SpringSource Tool Suite) version 2.3.0 Grails 1.2.1 Download the source code Java 1.6.x Groovy 1.7.x Download the source code Where can you go for help? Grails Portal Site http://code.google.com/p/grailsportal/ Grails Site http://www.grails.org Groovy Site http://groovy.codehaus.org/

Grails Portal Business Objects

Party Business Object A Party is an abstraction that signifies a specific individual that takes part in the system, but not necessarily only a person. It could be a system, individual user, or anything that can be identified by First Name and Last Name. These fields are the mandatory fields on the equivalent domain class. The Party class holds all of the information that composes an individual that participates in the functionality of the Portal.

Order Business Object The Order is an abstraction of the concept of Orders and fulfillment. This abstraction is important to the implementation of any selection for action from the website. Orders are done to establish that something needs to happen. Order Line items are created to track the specific Products that are selected by the user.

Product Business Object Products are an abstraction of the concept of any item that can be selected by a user. They are an abstract concept that is not necessarily something for sale. Products have line items that enable bundling of products into a larger product

Event Business Object Events are an abstraction of the concept of an occurrence of a business event. The recording of different types of business events enable business processes to be recorded along with all of the information associated with the process. The implementation of this Portal uses the Grails Web- Flow plug-in to initiate business events and track the progress of these events.

Grails Portal Domain Classes The tostring() method is implemented in each of the domain classes in this application. This is used in Grails scaffolding. Constraints are used in the domain classes to have a direct impact on how default Grails scaffolding generates controllers and views. In this application the blank:true and size:x x+n are commonly used to control how the fields are generated when they are generated through scaffolding. The nullable constraint relates directly back to how the domain class is generated into a table in that it makes the column mandatory (not null). Also, the size constraint gives the indication for how large the field will be in the database. All of the domain classes implement Serializable. This is mandatory if Grails Web-Flow plug-in is used.

Grails Portal Business Process Management using Grails Web-Flow Plug-in

Introduction to Grails Web-Flow Most web applications collect information in a stepwise fashion and then make business rule decisions based upon the data collected to accomplish some business functionality. This is a common requirement in any application, from a simple contact page to a commercial order management system. These types of requirements have been fulfilled in the past in many different ways.

Issues Grails Web-Flow Can Solve Termination/re-entry Workflow state Workflow Implementation Complexity

Grails Web-Flow It uses the well known Spring Web-Flow framework to manage the workflow. This framework handles the persistence of the workflow state and manages the issues when the refresh and back buttons are hit by the user during a workflow session. Its convention-based paradigm of Groovy simplifies the development process to implement the flows in a concise, understandable manner. Flows are created in a manner consistent with other Grails development. Grails domain classes make it simple to save the result of the workflow.

Grails Web-Flow Definition There are many types of workflow processes that exist, but it should be known that not all business flows lend themselves to being defined using Grails Web-Flow. There are three basic types of workflow: Human-based workflow This type of workflow is based upon the recording of activities strictly done by a human being where the intervals between recordings are extended and are not immediately ongoing. This can be, for example, the recording of a task such as a set of tests. Grails Web-Flow does not by default implement this type of workflow very well because it does not have the ability to re-constitute a workflow once the workflow session has been interrupted due to inactivity. Computer-based workflow This instance is where Grails Web-Flow shines. As in most web applications implemented using Grails Web-Flow, the intention is to collect data and guide the user between screens in one flow session. Mixed workflow (computer and human) used in Grails Portal A combination of the first two types, this hybrid workflow concept is a common reality when designing web applications. Grails Web-Flow can also implement this situation with a combination of traditional Grails web development and linked flows.

Grails Web-Flow Quick How To Planning is essential for success when defining a flow within a Grails application and all business processes can be distilled down to a basic set of steps. Whether you use a napkin or a formal diagram to document them, it is essential that you understand the required steps needed to implement the business process in your Grails application. In Grails Web-Flow, you take each of the steps and create a Groovy closure to capture the functionality. If you follow the normal process of GSP and Spring MVC web application development, you will find there are some slight adjustments required to enable flows to work.

Understanding Grails Web-Flow The name of the flow is described by adding the Flow word to the end of a closure in your controller. When you create the views, you must use the same name as the web-flow as a directory that contains the views for the web-flow. Navigating between the web-flows is pretty simple: The name property of the submit button for the pages in the flow indicates which closure to execute when the page is submitted. If the user navigates away from the flow, it is possible to re-establish the flow. Once the user ends the flow by hitting cancel, you have the ability to manage the data within the flow. Use the flow variable to store information for the span of a flow. The default context in a view used for a web-flow uses the flow variable. In your controller you should always have explicit entry points and exit points from the web-flow. This can be implemented by creating a default closure that will be used by the web-flow.

Web-Flow Best Practices Always use a service class when handling GORM objects. Either create a Grails service class or identify one that you will use to handle the saving of the data from the flow. Create a method to move the data from the posted web parameters to the domain objects. This process can vary widely in complexity. One of the easiest ways to do this is to have the names of the items on the view the same as the ones in your domain class. If you do this you can just instantiate the class using the parms variable it can be that simple! Create a custom Java Exception class similar to ValidationException. Make sure that you have a try, catch block around the call to catch a validation error. Write a method in service class to validate the domain object. If there is an error, throw a custom validation error that will show to the user the field that needs to be changed. Handle the exception. If there is an exception, make sure the appropriate values are set in the view, and return the model. If there is no exception, create the model objects needed and move the flow to the next page.

Web-Flow Demo From Grails Portal Code

Grails Portal Views

Grails Portal Views Using Ajax The decision was made to use the GrailsUI plug-in for implementing Ajax and Web 2.0 functionality within the Grails portal. This plug-in has a few major advantages: It fully uses the standard view functionality within Grails, adhering to the principles that I have laid out for the rest of the portal. It uses the Yahoo UI and Bubbling JavaScript libraries which are rich in functionality, but also very stable. It implements a minimal set of tag libraries which are easy to use and not too obtrusive to my existing GSP pages. It allows me to create my own set of tag libraries to implement functionality that doesn't exist in the GrailsUI tags without conflicts. It references the YahooUI JavaScript library is very well documented in theyahoo developer site.

Why are Grails Tag libraries so popular? A simple explanation would be that they are much easier to to develop than Java tag libraries. Grails tag libraries can be developed quickly, easily, and take much of the frustration out of user interface development when done in a pragmatic manner. In the chosen style of development for the Grails portal, JavaScript is doing much of the work to handle the user interaction in the web browser; consequently, the view files (GSP) often become a set of confusing CSS and JavaScript combined with Grails tags. With custom Grails tags in place this issue is reduced to a point where views are easily maintained. The implementation of the user interface functionality becomes more generic, and therefore increasingly adaptable when JavaScript libraries change.

Creating a Tag Library Demo From Grails Portal Code

Grails Portal Visions for the Future

Future Functionality Take advantage fully of Grails 1.2 features: Use of Packages for Domain and Controller classes. DSL s for configuration More Dynamic Functionality Improved database flexibility and functionality Dynamic Attributes Full implementation of Ajax style user interface through scaffolding. Context based scaffolding Daisy Content Management System integration

Demo of Future Functionality

Questions? Comments? Joshua Davis Twitter joshuad2 Email joshua.davis@cognizant.com LinkedIn, CodeTown Joshua Davis Groovy/Grails Magazine Author

Grails Portal Cheat Sheet Database - Grails Portal use of GORM Security - Shiro Plugin Presentation YahooUI Plugin Bubbling Plugin GrailsUI Plugin Custom GSP Tag Libraries Business Process - Web-Flow Plugin Administration - Grails Scaffolding

References Shiro plugin: http://www.grails.org/plugin/shiro GrailsUI plugin: http://grails.org/plugin/grails-ui YahooUI plugin: http://www.grails.org/yui%20plugin Bubbling plugin: http://grails.org/bubbling%20plugin Grails Framework Reference Guide: http://grails.org/doc/1.21/ Java Serialization: http://java.sun.com/developer/technicalarticles/programming /serialization/ The Definitive Guide to Grails (second edition) by Graeme Rocher and Jeff Brown ISBN: 9781590599952 Enterprise Patterns and MDA: Building Better Software with Achetype Patterns and UML by Jim Arlow, Ila Neustadt Addison Wesley Press ISBN-13: 978-0321112309