30
Published under the Creative Commons Attribution Noncommercial Share Alike License Version 2.5. (Please see http://creativecommons.org/licenses/by-nc-sa/2.5 for complete details.) Going Further with Grails Jason Rudolph [email protected]

Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph [email protected]. Introduction

  • Upload
    dothuy

  • View
    219

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Published under the Creative Commons Attribution Noncommercial Share Alike License Version 2.5. (Please see http://creativecommons.org/licenses/by-nc-sa/2.5 for complete details.)

Going Further with Grails

Jason [email protected]

Page 2: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Introduction

Jason Rudolph

jasonrudolph.com

thinkrelevance.com

Page 3: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Agenda

Beyond scaffolding

When the UI and the DB disagree

DRY UI

Business logic, right where it belongs

Calling in the Java infantry

Security? Just plug it in

Page 4: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

scaffolding.next()Demo

Page 5: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Tag Libraries

Pre-packaged tags

Logical - if, else, etc.

Iterative - while, each, findAll, etc.

Form - textField, checkBox, datePicker, etc.

Rendering - layoutBody, paginate, etc.

Ajax - remoteField, submitToRemote, etc.

And others...

Page 6: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Tag Libraries (cont’d)Custom tags

Named (and found by Grails) using convention

Names end with "TagLib" (e.g., RacetrackTagLib.groovy)

Located in grails-app/taglib

Implemented as closures

No TLDs necessary

User-contributed tags

Page 7: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Command & ConquerDemo

Page 8: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Command Objects

Why?

Business objects minus persistence, or

View-centric adaption of the domain

Auto-populated from request params

Play nicely with constraints

At home in src/groovy, grails-app/controllers, or directly inside the controller

Page 9: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

“Flash” Cards

Page 10: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

redirect_after_post == good

Page 11: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

!manual_session_cleanup

Page 12: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

request < flash < session

Page 13: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

flash.lifetime == request.lifetime++

Page 14: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Talking BackDemo

Page 15: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

LayoutsPowered by SiteMesh

A home for common site assets

Menus, headers, footers

Global CSS and JavaScript

Global metadata

Precedence rules

Explicitly declared layouts

Layout by convention

Page 16: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Where’s My Layout?

1. Is it declared in the view?

<meta name="layout" content="foo" />

2. Fallback to convention. Layout for this view?

/views/layouts/sponsorship/create.gsp

3. Layout for this controller?

/views/layouts/sponsorship.gsp

4. Punt!

Rendering views/sponsorship/create.gsp ...

Page 17: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Partial Templates

Why? DRY UI!

Naming

Locating

Passing variables

bean

collection

hash

Page 18: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

It’s All Relative

<!-- ... --><g:render template="foo"><!-- ... -->

views/sponsorship/create.gsp

Page 19: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

From the Top

<!-- ... --><g:render template="/shared/foo"><!-- ... -->

views/sponsorship/create.gsp

Page 20: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Partial Templates

Why? DRY UI!

Naming

Locating

Passing variables

bean

collection

hash

Page 21: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

At Your ServiceDemo

Page 22: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Services

Declarative transactionality

Flexible scoping

Zero-configuration dependency injection

Page 23: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Calling All JARsDemo

Page 24: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Security

Authenticate

Authorize

Administer

http://www.flickr.com/photos/amagill/235453953/Used under Creative Commons Attribution 2.0 Generic License (http://creativecommons.org/licenses/by/2.0/deed.en-us)

Page 25: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Acegi Plugin

User account management

Password encryption

Log in & log out interface

Role management

Resource management

Hide/show UI elements based on user roles

Registration e-mails

Page 26: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Lock-downDemo

Page 27: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Whew!

It ain’t just scaffolding

The UI and the DB needn’t always agree

Banishing UI redundancy

Thin controllers, fat services

Java at your fingertips

Plug in and go

Page 28: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Resources

grails.org

Downloads

Latest Release (1.0.1)

Development Snapshot (1.0.2)

User guide, tutorials, screencasts, etc.

Mailing lists (grails.org/mailing+lists)

Page 29: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction
Page 30: Going Further with Grails - Jason Rudolphjasonrudolph.com/downloads/presentations/Going_Further_with_Grails.pdfGoing Further with Grails Jason Rudolph jason@thinkrelevance.com. Introduction

Slides & Examples Available

@

jasonrudolph.com/downloads

Please Fill Out Your Evaluations

This presentation is published under the Creative Commons Attribution Noncommercial Share Alike License Version 2.5.

(Please see http://creativecommons.org/licenses/by-nc-sa/2.5 for complete details.)