ebook img

Lift in action : the simply functional web framework for Scala PDF

426 Pages·2012·11.803 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Lift in action : the simply functional web framework for Scala

The simply functional web framework for Scala Covers Lift 2.x Timothy Perrett M A N N I N G Lift in Action Lift in Action THE SIMPLY FUNCTIONAL WEB FRAMEWORK FOR SCALA TIMOTHY PERRETT MANNING SHELTER ISLAND 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: [email protected] ©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. Development editors: Katharine Osborne 20 Baldwin Road Copyeditor: Andy Carroll PO Box 261 Typesetter: Dennis Dalinnik Shelter Island, NY 11964 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 brief contents PART 1 GETTING STARTED........................................................1 1 ■ Introducing Lift 3 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 vi BRIEF CONTENTS 12 ■ Localization 282 13 ■ Distributed messaging and Java enterprise integration 293 14 ■ Application testing 317 15 ■ Deployment and scaling 347 contents preface xiii acknowledgments xv about this book xvii about the author xxi about the cover illustration xxii 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 viii CONTENTS 2 Hello Lift 20 2.1 Getting started with SBT 21 2.2 Your first Lift application 23 Creating the project 23 ■ Inspecting the project 26 Booting the application 29 2.3 Snippets and templating overview 31 Snippets 31 ■ Templating overview 33 2.4 Summary 35 PART 2 APPLICATION TUTORIAL ..................................37 3 The auction application 39 3.1 Application requirements 40 Frontend 40 ■ Administration 41 3.2 Template structure 43 Design workflow 43 ■ Template setup 43 3.3 Data models 46 Schema definition 46 ■ Connecting to the database 49 3.4 Scaffolding 50 Prototype traits 50 ■ CRUD generation 53 3.5 Validation 57 Definitions 58 ■ Displaying field errors 58 3.6 Summary 59 4 Customers, auctions, and bidding 60 4.1 Building an auction catalog 61 Listing auctions 61 ■ Adding to SiteMap 65 4.2 Displaying auctions 66 Auction detail URLs 66 ■ The AJAX bidding interface 68 ■ Real-time bidding 74 4.3 Summary 82 CONTENTS ix 5 Shopping basket and checkout 83 5.1 Order creation 84 Order models 84 ■ Attributing auctions to customers 87 5.2 Implementing the basket and checkout process 91 Implementing the basket 91 ■ Implementing the checkout 93 5.3 Collecting payment with PayPal 99 Environment setup 99 ■ The Buy Now button 102 5.4 Summary 103 PART 3 LIFT IN DETAIL..............................................105 6 Common tasks with Lift WebKit 107 6.1 Templates, snippets, and views 108 Templates 108 ■ Snippets 114 ■ Views 125 6.2 Managing state 128 Request and session state 128 ■ Cookies 130 6.3 Forms with LiftScreen and Wizard 131 LiftScreen 132 ■ Wizard 135 6.4 Widgets 137 AutoComplete widget 137 ■ Gravatar widget 138 6.5 Summary 139 7 SiteMap and access control 140 7.1 Menus and locations 141 Understanding and implementing locations 143 Rendering menus 143 7.2 Location parameters 146 Default location parameters 147 Authentication parameters 150 7.3 Customizing SiteMap 153 Creating a custom Loc 153 ■ When to customize SiteMap? 158 7.4 Summary 159

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.