logo资料库

lift in action.pdf

第1页 / 共426页
第2页 / 共426页
第3页 / 共426页
第4页 / 共426页
第5页 / 共426页
第6页 / 共426页
第7页 / 共426页
第8页 / 共426页
资料共426页,剩余部分请下载后查看
Front cover
brief contents
contents
preface
acknowledgments
about this book
Roadmap
Who should read this book?
Code conventions and examples
Author Online
about the author
about the cover illustration
Part 1 — Getting started
Introducing Lift
1.1 What is Scala?
1.2 What is Lift?
1.2.1 Lift design goals
1.2.2 View-first design
1.2.3 Community and team
1.3 Lift features
1.3.1 Lift Core and Lift Web
1.3.2 Lift Persistence
1.3.3 Lift Modules
1.4 Summary
Hello Lift
2.1 Getting started with SBT
2.2 Your first Lift application
2.2.1 Creating the project
2.2.2 Inspecting the project
2.2.3 Booting the application
2.3 Snippets and templating overview
2.3.1 Snippets
2.3.2 Templating overview
2.4 Summary
Part 2 — Application tutorial
The auction application
3.1 Application requirements
3.1.1 Frontend
3.1.2 Administration
3.2 Template structure
3.2.1 Design workflow
3.2.2 Template setup
3.3 Data models
3.3.1 Schema definition
3.3.2 Connecting to the database
3.4 Scaffolding
3.4.1 Prototype traits
3.4.2 CRUD generation
3.5 Validation
3.5.1 Definitions
3.5.2 Displaying field errors
3.6 Summary
Customers, auctions, and bidding
4.1 Building an auction catalog
4.1.1 Listing auctions
4.1.2 Adding to SiteMap
4.2 Displaying auctions
4.2.1 Auction detail URLs
4.2.2 The AJAX bidding interface
4.2.3 Real-time bidding
4.3 Summary
Shopping basket and checkout
5.1 Order creation
5.1.1 Order models
5.1.2 Attributing auctions to customers
5.2 Implementing the basket and checkout process
5.2.1 Implementing the basket
5.2.2 Implementing the checkout
5.3 Collecting payment with PayPal
5.3.1 Environment setup
5.3.2 The Buy Now button
5.4 Summary
Part 3 — Lift in detail
Common tasks with Lift WebKit
6.1 Templates, snippets, and views
6.1.1 Templates
6.1.2 Snippets
6.1.3 Views
6.2 Managing state
6.2.1 Request and session state
6.2.2 Cookies
6.3 Forms with LiftScreen and Wizard
6.3.1 LiftScreen
6.3.2 Wizard
6.4 Widgets
6.4.1 AutoComplete widget
6.4.2 Gravatar widget
6.5 Summary
SiteMap and access control
7.1 Menus and locations
7.1.1 Understanding and implementing locations
7.1.2 Rendering menus
7.2 Location parameters
7.2.1 Default location parameters
7.2.2 Authentication parameters
7.3 Customizing SiteMap
7.3.1 Creating a custom Loc
7.3.2 When to customize SiteMap?
7.4 Summary
HTTP in Lift
8.1 HTTP pipeline
8.1.1 HTTP abstraction
8.1.2 Application lifecycle
8.1.3 Request lifecycle
8.2 URL rewriting
8.2.1 Defining a RewritePF
8.2.2 Advanced rewriting
8.3 Dispatching and web services
8.3.1 Using the HTTP dispatch DSL
8.3.2 Basic REST service
8.3.3 Advanced multiformat REST service
8.4 Summary
AJAX, wiring, and Comet
9.1 AJAX
9.1.1 JavaScript abstractions
9.1.2 AJAX 101
9.1.3 Sophisticated AJAX
9.1.4 Using JSON forms with AJAX
9.1.5 AJAX with LiftScreen
9.2 Wiring
9.2.1 Formula wiring
9.3 Comet
9.3.1 What are actors?
9.3.2 Basic Comet usage
9.3.3 Comet-based rock-paper-scissors
9.4 Summary
Persistence with Mapper
10.1 Setting up a database
10.1.1 Installation and connectivity
10.1.2 Defining Mappers
10.1.3 Relationships
10.1.4 Schema creation and control
10.2 Interacting with Mapper
10.2.1 Creating data
10.2.2 Querying data
10.2.3 Updating and deleting data
10.2.4 Validation and lifecycle callbacks
10.2.5 Display functionality
10.3 Advanced Mapper
10.3.1 Query logging
10.3.2 Transactions
10.3.3 Custom mapped fields
10.4 Summary
Persistence with Record
11.1 Common Record functionality
11.1.1 Common Record fields
11.1.2 Integration with LiftScreen and Wizard
11.2 Record for relational databases
11.2.1 Connecting and querying with Squeryl
11.2.2 A bookstore with Squeryl
11.3 Record for NoSQL stores
11.3.1 NoSQL support in Lift
11.3.2 Bookstore with MongoDB
11.4 Summary
Localization
12.1 Implementing localization
12.1.1 Implementing locale calculator
12.1.2 Localizing templates and code
12.2 Defining localized resources
12.2.1 Using XML resources
12.2.2 Using Java properties resources
12.2.3 Using custom resource factories
12.3 Summary
Distributed messaging and Java enterprise integration
13.1 Distributed programming
13.1.1 Messaging with AMQP
13.1.2 Messaging with Akka
13.2 Integrating Lift into existing Java infrastructure
13.2.1 JPA and Scala EntityManager
13.3 Summary
Application testing
14.1 Scala testing frameworks
14.1.1 ScalaTest
14.1.2 Scala Specs
14.1.3 ScalaCheck
14.1.4 Code coverage reports
14.2 Writing testable code
14.2.1 Complexities of testing state
14.2.2 Dependency injection
14.3 Testing strategies
14.3.1 Testing snippets
14.3.2 Testing web services
14.3.3 Testing with Mapper
14.3.4 Testing Comet and AJAX
14.4 Summary
Deployment and scaling
15.1 Choosing a servlet container
15.2 Handling state
15.2.1 Sticky session strategies
15.2.2 Distributing critical state
15.3 Choosing a configuration
15.3.1 Single server
15.3.2 Multiple servers
15.4 Deployment tools and techniques
15.4.1 Built-in assistance
15.4.2 Monitoring
15.5 Case studies
15.5.1 Foursquare
15.5.2 Novell Vibe
15.6 Summary
appendix A: Introduction to Scala
A.1 Variables, values, and immutability
A.2 Classes, methods, traits, and functions
A.2.1 Classes
A.2.2 Traits
A.2.3 Methods
A.2.4 Functions
A.3 Collections
A.4 Pattern matching
A.5 Implicits
appendix B: Configuring an IDE
B.1 IntelliJ
B.2 Eclipse
appendix C: Options and boxes
index
Symbols
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Back cover
The simply functional web framework for Scala Covers Lift 2.x Timothy Perrett M A N N I N G www.it-ebooks.info
Lift in Action www.it-ebooks.info
www.it-ebooks.info
Lift in Action THE SIMPLY FUNCTIONAL WEB FRAMEWORK FOR SCALA TIMOTHY PERRETT M A N N I N G SHELTER ISLAND www.it-ebooks.info
To my Dad for teaching me that hard work and dedication can triumph over any problem For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 261 Shelter Island, NY 11964 Email: orders@manning.com ©2012 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine. Manning Publications Co. 20 Baldwin Road PO Box 261 Shelter Island, NY 11964 Development editors: Katharine Osborne Copyeditor: Andy Carroll Typesetter: Dennis Dalinnik Cover designer: Marija Tudor ISBN: 9781935182801 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – MAL – 17 16 15 14 13 12 11 www.it-ebooks.info
brief contents PART 1 GETTING STARTED ........................................................1 Introducing Lift 3 1 ■ 2 ■ Hello Lift 20 PART 2 APPLICATION TUTORIAL ..............................................37 3 ■ The auction application 39 4 ■ Customers, auctions, and bidding 60 5 ■ Shopping basket and checkout 83 PART 3 LIFT IN DETAIL..........................................................105 6 ■ Common tasks with Lift WebKit 107 7 ■ SiteMap and access control 140 8 ■ HTTP in Lift 160 9 ■ AJAX, wiring, and Comet 187 10 ■ Persistence with Mapper 223 11 ■ Persistence with Record 259 v www.it-ebooks.info
vi BRIEF CONTENTS 12 ■ Localization 282 13 ■ Distributed messaging and Java enterprise integration 293 14 ■ Application testing 317 15 ■ Deployment and scaling 347 www.it-ebooks.info
contents xiii preface acknowledgments about this book about the author about the cover illustration xxii xv xvii xxi PART 1 GETTING STARTED.............................................1 1 Introducing Lift 3 1.1 What is Scala? 4 1.2 What is Lift? 6 Lift design goals 7 ■ View-first design 8 Community and team 10 1.3 Lift features 11 Lift Core and Lift Web 12 ■ Lift Persistence 15 Lift Modules 17 1.4 Summary 18 vii www.it-ebooks.info
分享到:
收藏