21
Discussion document – Strictly Confidential & Proprietary An Introduction to Lift Dallas, TX May 02, 2012

Dallas GUG Lift Presentation

Embed Size (px)

Citation preview

Page 1: Dallas GUG Lift Presentation

Discussion document – Strictly Confidential & Proprietary

An Introduction to LiftDallas, TXMay 02, 2012

Page 2: Dallas GUG Lift Presentation

An Introduction to Lift

2May 2, 2012

Agenda …

Where are we going?

• Scala Web Frameworks

• Why is Lift Different

• In the Wild

• The Basics of Lift

– Getting Up and Running

– Building Blocks

– Page Templates

– Snippets

– Model

– Business Logic

Page 3: Dallas GUG Lift Presentation

An Introduction to Lift

3May 2, 2012

Agenda …

Goals

• Have an understanding of what Lift is

• Have an interest in learning more

• Go play with Lift!

Page 4: Dallas GUG Lift Presentation

An Introduction to Lift

4May 2, 2012

Scala Web Frameworks …

What web frameworks are available for Scala?

Minimalist• Scalatra

– Leveraged primarily for RESTful services

– Used by LinkedIn for RESTful services supporting mobile platform

• Unfiltered

– Provides a consistent API for handling HTTP requests on various server backends

– Used by Meetup for real-time APIs

Full Stack• Includes ORM, view and state management

• Play

– MVC Model

– Scala styling for the Java web framework

– Supported framework of Typesafe

• Lift

Page 5: Dallas GUG Lift Presentation

An Introduction to Lift

5May 2, 2012

Why is Lift Different …

Seven Things

Lift offers seven things that differentiate it from other frameworks• Lazy loading

– Render page to browser while waiting for computation to complete

– Once complete, render remaining HTML

• Parallel page rendering

– By labeling a snippet parallel, Lift will forward snippet to another thread in a pool of threads

– When all threads are completed, results are combined and page is sent to browser

• Comet and AJAX

– Server push – long poll wait for AJAX response

• Wiring

– Interdependent page elements can be associated to one another

– If a precedent element changes, dependent items are redisplayed on the next HTTP response

• Designer friendly templates

• Wizard

– Define multi-page input screens with field and form level validation

• Security

Page 6: Dallas GUG Lift Presentation

An Introduction to Lift

6May 2, 2012

Why is Lift Different … Security …

Security

Lift can withstand many of the OWASP Top 10 Security Vulnerabilities• Injection – Lift’s Mapper and Record libraries properly escape query strings before being sent to the

backing store

• XSS – Lift holds the rendered pages as a DOM until late in the page rendering cycle, allowing it to automatically HTML escape Strings before sending to the browser

• Session Management – Lift uses the JEE container’s session management and keeps passwords hashed at all times with per-row salt

• CSRF – Lift uses session-specific bindings between HTML elements and the server-side behaviors associated with those elements. Bindings cannot be predicted, so cross site requests of session-specific bindings is impossible

• URL Access – Lift provides declarative rules for access to URLs. Access will be denied to a URL unless the criteria is met for accessing the specific URL

Page 7: Dallas GUG Lift Presentation

An Introduction to Lift

7May 2, 2012

In the Wild …

Lift is gaining traction

· OpenStudy – Collaborative learning tool used by MIT and many other top universities.

· FourSquare – Message queue in pure Scala. Website, mobile website and RESTful API running on Lift.

· StackMob– ‘Heroku for Mobile’.

· Novell – Pulse, a cloud-based, real-time collaboration platform for the enterprise. Utilizes Scala and Lift.

Page 8: Dallas GUG Lift Presentation

An Introduction to Lift

8May 2, 2012

The Basics of Lift...

What you need to know to get started!

• Getting Up and Running

• Building Blocks

• Page Templates

• Snippets

• Model

• Business Logic

Page 9: Dallas GUG Lift Presentation

An Introduction to Lift

9May 2, 2012

The Basics of Lift …

Getting up and running

Required• Java 1.5 or greater

• Scala 2.9.1 distribution

• SBT – Simple Build Tool

• Lift 2.4

Optional• sbteclipse – create .project for Eclipse

• IDE Plugin

– ScalaIDE (Eclipse – must use Helios)

– Scala Plugin for IntelliJ IDEA

– Scala Plugin for NetBeans

Notes:

1) Installation of Scala and SBT involve expanding compressed file and adding to PATH

2) IDE installation varies by tool; some dependency on IDE release number

3) ScalaIDE officially supported by Typesafe

Page 10: Dallas GUG Lift Presentation

An Introduction to Lift

10May 2, 2012

The Basics of Lift … Building Blocks …

Building Blocks

Page 11: Dallas GUG Lift Presentation

An Introduction to Lift

11May 2, 2012

The Basics of Lift … Page Templates …

Page Templates

Page 12: Dallas GUG Lift Presentation

An Introduction to Lift

12May 2, 2012

The Basics of Lift … Page Templates …

Page Templates

Templates• A template is a well formed, designer friendly XML document

• Code cannot creep into the document

• Special tags to reference snippets

Example

Page 13: Dallas GUG Lift Presentation

An Introduction to Lift

13May 2, 2012

The Basics of Lift … Snippets …

Snippets

Page 14: Dallas GUG Lift Presentation

An Introduction to Lift

14May 2, 2012

The Basics of Lift … Snippets …

Snippets

Snippets• Any template element in the lift: or l: name space indicates a snippet

• Snippets are functions that transform the invocating element into a new node

• There can be multiple snippets per template

• Snippets are evaluated in the order they are encountered

• Processed serially, unless marked as parallel=true

Example

Page 15: Dallas GUG Lift Presentation

An Introduction to Lift

15May 2, 2012

The Basics of Lift … Model …

Model and Persistence

Page 16: Dallas GUG Lift Presentation

An Introduction to Lift

16May 2, 2012

The Basics of Lift … Model …

Model

Model• The model is the object representation of your persistence store

• Lift includes two options Mapper and Record

• Mapper typically used for relational databases

• Record typically used for NoSQL datastores

Example

Page 17: Dallas GUG Lift Presentation

An Introduction to Lift

17May 2, 2012

The Basics of Lift … Business Logic …

Your Business Logic

Page 18: Dallas GUG Lift Presentation

An Introduction to Lift

18May 2, 2012

The Basics of Lift … Model …

Model

Model• The model is the object representation of your persistence store

• Lift includes two options Mapper and Record

• Mapper typically used for relational databases

• Record typically used for NoSQL datastores

Example

Page 19: Dallas GUG Lift Presentation

An Introduction to Lift

19May 2, 2012

The Basics of Lift … Business Logic …

Your Business Logic

Business Logic• Business logic resides in the lib directory

Example

Page 20: Dallas GUG Lift Presentation

An Introduction to Lift

20

Web Resources

May 2, 2012

Appendix … Web References ...

Resources

Description Link

Scala http://www.scala-lang.org

SBT – Simple Build Tool http://github.com/harrah/xsbt

ScalaIDE for Eclipse http://scala-ide.org

Scala Plugin for IntelliJ IDEA http://confluence.jetbrains.net/display/SCA/Scala_Plugin+for+IntelliJ+IDEA

Scala Plugin for NetBeans http://wiki.netbeans.org/Scala

Lift http://liftweb.net

Page 21: Dallas GUG Lift Presentation

An Introduction to Lift

21May 2, 2012

Contact ...

Contact Me!

[email protected]

@brentlemons

slideshare.net/brentlemons