Table of Contents

Copyright

Brief Table of Contents

Table of Contents

Foreword

Preface

Acknowledgments

About this Book

About the Cover Illustration

1. Getting started

Chapter 1. Introduction to Play 2

1.1. What Play is

1.1.1. Key features

1.1.2. Java and Scala

1.1.3. Play isn’t Java EE

1.2. High-productivity web development

1.2.1. Working with HTTP

1.2.2. Simplicity, productivity, and usability

1.3. Why Scala needs Play

1.4. Type-safe web development—why Play needs Scala

1.5. Hello Play!

1.5.1. Getting Play and setting up the Play environment

1.5.2. Creating and running an empty application

1.5.3. Play application structure

1.5.4. Accessing the running application

1.5.5. Add a controller class

1.5.6. Add a compilation error

1.5.7. Use an HTTP request parameter

1.5.8. Add an HTML page template

1.6. The console

1.7. Summary

Chapter 2. Your first Play application

2.1. The product list page

2.1.1. Getting started

2.1.2. Stylesheets

2.1.3. Language localization configuration

2.1.4. Adding the model

2.1.5. Product list page

2.1.6. Layout template

2.1.7. Controller action method

2.1.8. Adding a routes configuration

2.1.9. Replacing the welcome page with a redirect

2.1.10. Checking the language localizations

2.2. Details page

2.2.1. Model finder method

2.2.2. Details page template

2.2.3. Additional message localizations

2.2.4. Adding a parameter to a controller action

2.2.5. Adding a parameter to a route

2.2.6. Generating a bar code image

2.3. Adding a new product

2.3.1. Additional message localizations

2.3.2. Form object

2.3.3. Form template

2.3.4. Saving the new product

2.3.5. Validating the user input

2.3.6. Adding the routes for saving products

2.4. Summary

2. Core functionality

Chapter 3. Deconstructing Play application architecture

3.1. Drawing the architectural big picture

3.1.1. The Play server

3.1.2. HTTP

3.1.3. MVC

3.1.4. REST

3.2. Application configuration—enabling features and changing defaults

3.2.1. Creating the default configuration

3.2.2. Configuration file format

3.2.3. Configuration file overrides

3.2.4. Configuration API—programmatic access

3.2.5. Custom application configuration

3.3. The model—adding data structures and business logic

3.3.1. Database-centric design

3.3.2. Model class design

3.3.3. Defining case classes

3.3.4. Persistence API integration

3.3.5. Using Slick for database access

3.4. Controllers—handling HTTP requests and responses

3.4.1. URL-centric design

3.4.2. Routing HTTP requests to controller action methods

3.4.3. Binding HTTP data to Scala objects

3.4.4. Generating different types of HTTP response

3.5. View templates—formatting output

3.5.1. UI-centric design

3.5.2. HTML-first templates

3.5.3. Type-safe Scala templates

3.5.4. Rendering templates—Scala template functions

3.6. Static and compiled assets

3.6.1. Serving assets

3.6.2. Compiling assets

3.7. Jobs—starting processes

3.7.1. Asynchronous jobs

3.7.2. Scheduled jobs

3.7.3. Asynchronous results and suspended requests

3.8. Modules—structuring your application

3.8.1. Third-party modules

3.8.2. Extracting custom modules

3.8.3. Module-first application architecture

3.8.4. Deciding whether to write a custom module

3.8.5. Module architecture

3.9. Summary

Chapter 4. Defining the application’s HTTP interface

4.1. Designing your application’s URL scheme

4.1.1. Implementation-specific URLs

4.1.2. Stable URLs

4.1.3. Java Servlet API—limited URL configuration

4.1.4. Benefits of good URL design

4.2. Controllers—the interface between HTTP and Scala

4.2.1. Controller classes and action methods

4.2.2. HTTP and the controller layer’s Scala API

4.2.3. Action composition

4.3. Routing HTTP requests to controller actions

4.3.1. Router configuration

4.3.2. Matching URL path parameters that contain forward slashes

4.3.3. Constraining URL path parameters with regular expressions

4.4. Binding HTTP data to Scala objects

4.5. Generating HTTP calls for actions with reverse routing

4.5.1. Hardcoded URLs

4.5.2. Reverse routing

4.6. Generating a response

4.6.1. Debugging HTTP responses

4.6.2. Response body

4.6.3. HTTP status codes

4.6.4. Response headers

4.6.5. Serving static content

4.7. Summary

Chapter 5. Storing data—the persistence layer

5.1. Talking to a database

5.1.1. What are Anorm and Squeryl?

5.1.2. Saving model objects in a database

5.1.3. Configuring your database

5.2. Creating the schema

5.3. Using Anorm

5.3.1. Defining your model

5.3.2. Using Anorm’s stream API

5.3.3. Pattern matching results

5.3.4. Parsing results

5.3.5. Inserting, updating, and deleting data

5.4. Using Squeryl

5.4.1. Plugging Squeryl in

5.4.2. Defining your model

5.4.3. Extracting data—queries

5.4.4. Saving records

5.4.5. Handling transactions

5.4.6. Entity relations

5.5. Caching data

5.6. Summary

Chapter 6. Building a user interface with view templates

6.1. The why of a template engine

6.2. Type safety of a template engine

6.2.1. A not type-safe template engine

6.2.2. A type-safe template engine

6.2.3. Comparing type-safe and not type-safe templates

6.3. Template basics and common structures

6.3.1. @, the special character

6.3.2. Expressions

6.3.3. Displaying collections

6.3.4. Security and escaping

6.3.5. Using plain Scala

6.4. Structuring pages: template composition

6.4.1. Includes

6.4.2. Layouts

6.4.3. Tags

6.5. Reducing repetition with implicit parameters

6.6. Using LESS and CoffeeScript: the asset pipeline

6.6.1. LESS

6.6.2. CoffeeScript

6.6.3. The asset pipeline

6.7. Internationalization

6.7.1. Configuration and message files

6.7.2. Using messages in your application

6.8. Summary

Chapter 7. Validating and processing input with the forms API

7.1. Forms—the concept

7.1.1. Play 1.x forms reviewed

7.1.2. The Play 2 approach to forms

7.2. Forms basics

7.2.1. Mappings

7.2.2. Creating a form

7.2.3. Processing data with a form

7.2.4. Object mappings

7.2.5. Mapping HTTP request data

7.3. Creating and processing HTML forms

7.3.1. Writing HTML forms manually

7.3.2. Generating HTML forms

7.3.3. Input helpers

7.3.4. Customizing generated HTML

7.4. Validation and advanced mappings

7.4.1. Basic validation

7.4.2. Custom validation

7.4.3. Validating multiple fields

7.4.4. Optional mappings

7.4.5. Repeated mappings

7.4.6. Nested mappings

7.4.7. Custom mappings

7.4.8. Dealing with file uploads

7.5. Summary

3. Advanced concepts

Chapter 8. Building a single-page JavaScript application with JSON

8.1. Creating the single-page Play application

8.1.1. Getting started

8.1.2. Adding stylesheets

8.1.3. Adding a simple model

8.1.4. Page template

8.1.5. Client-side script

8.2. Serving data to a JavaScript client

8.2.1. Constructing JSON data value objects

8.2.2. Converting model objects to JSON objects

8.3. Sending JSON data to the server

8.3.1. Editing and sending client data

8.3.2. Consuming JSON

8.3.3. Consuming JSON in more detail

8.3.4. Reusable consumers

8.3.5. Combining JSON formatters and consumers

8.4. Validating JSON

8.4.1. Mapping the JSON structure to a model

8.4.2. Handling “empty” values

8.4.3. Adding validation rules and validating input

8.4.4. Returning JSON validation errors

8.4.5. Alternative JSON libraries

8.5. Authenticating JSON web service requests

8.5.1. Adding authentication to action methods

8.5.2. Using basic authentication

8.5.3. Other authentication methods

8.6. Summary

Chapter 9. Play and more

9.1. Modules

9.1.1. Using modules

9.1.2. Creating modules

9.2. Plugins

9.3. Deploying to production

9.3.1. Production mode

9.3.2. Working with multiple configurations

9.3.3. Creating native packages for a package manager

9.3.4. Setting up a front-end proxy

9.3.5. Using SSL

9.3.6. Deploying to a cloud provider

9.3.7. Deploying to an application server

9.4. Summary

Chapter 10. Web services, iteratees, and WebSockets

10.1. Accessing web services

10.1.1. Basic requests

10.1.2. Handling responses asynchronously

10.1.3. Using the cache

10.1.4. Other request methods and headers

10.1.5. Authentication mechanisms

10.2. Dealing with streams using the iteratee library

10.2.1. Processing large web services responses with an iteratee

10.2.2. Creating other iteratees and feeding them data

10.2.3. Iteratees and immutability

10.3. WebSockets: Bidirectional communication with the browser

10.3.1. A real-time status page using WebSockets

10.3.2. A simple chat application

10.4. Using body parsers to deal with HTTP request bodies

10.4.1. Structure of a body parser

10.4.2. Using built-in body parsers

10.4.3. Composing body parsers

10.4.4. Building a new body parser

10.5. Another way to look at iteratees

10.6. Summary

Index

List of Figures

List of Tables

List of Listings

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset