Play Framework Essentials
eBook - ePub

Play Framework Essentials

  1. 200 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Play Framework Essentials

Book details
Book preview
Table of contents
Citations

About This Book

Play is a framework to write web applications using Scala or Java. It provides a productive development environment, allowing you to just hit the "refresh" button in your browser to compile your changes and reload the application. Because of its stateless nature, the framework makes it easy to build applications that scale. Play provides a reactive programming model to harness the event-driven HTTP layer.

This book provides a step-by-step walkthrough of how to build a complete web application following best application development practices using Play framework 2. All aspects specific to web-oriented architectures are covered: the HTTP layer, JSON manipulation, HTML templating, asset compression and concatenation, form submission, content negotiation, security, and HTTP streaming. The book will also provide detailed architectural insights into Play framework to give you a better understanding in order to successfully build scalable applications.

Frequently asked questions

Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes, you can access Play Framework Essentials by Julien Richard-Foy in PDF and/or ePUB format, as well as other popular books in Computer Science & Web Development. We have over one million books available in our catalogue for you to explore.

Information

Year
2014
ISBN
9781783982400
Edition
1

Play Framework Essentials


Table of Contents

Play Framework Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Building a Web Service
Play – a framework used to write web applications
Bootstrapping a Play application
Play applications' layout
URL routing
Route path parameters
Parameters type coercion
Parameters with fixed values
Query string parameters
Default values of query string parameters
Trying the routes
Building HTTP responses
Serializing application data in JSON
Reading JSON requests
Validating JSON data
Handling optional values and recursive types
Summary
2. Persisting Data and Testing
Testing your web service
Writing and running tests
Testing the HTTP layer
Using the reverse router to generate URLs
Running a fake Play application
Effectively writing HTTP tests
Persisting data
Using a relational database
Getting a reference to the currently running application
Using a database management library
Using Slick in Scala
Using JPA in Java
Integrating with other persistence technologies
Populating the database with fixtures
The application's Global object
Managing database schema evolutions
Using an in-memory database for tests
Summary
3. Turning a Web Service into a Web Application
Delta between a web service and a web application
Using the template engine to build web pages
Inserting dynamic values
Looping and branching
Reusing document fragments
Comments
Import statements
Generating HTML forms
Repeated and nested fields
Reading and validating HTML form data
Handling the HTML form submission
Validating the HTML form data
The Scala form validation API
The Java form validation API
Optional and mandatory fields
Sharing JSON validation and HTML form validation rules
Handling content negotiation
Putting things together
Writing web user interface tests
Summary
4. Integrating with Client-side Technologies
Philosophy of Play regarding client-side technologies
Serving static assets
Sprinkling some JavaScript and CSS
Using the JavaScript reverse router
Managing assets from the build system
Producing web assets
Pipelining web assets' transformations
Concatenating and minifying JavaScript files
Gzipping assets
Fingerprinting assets
Managing JavaScript dependencies
Running JavaScript tests
Summary
5. Reactively Handling Long-running Requests
Play application's execution model
Scaling up your server
Embracing non-blocking APIs
Managing execution contexts
Writing incremental computations using iteratees
Streaming results using enumerators
Manipulating data streams by combining iteratees, enumerators, and enumeratees
Unidirectional streaming with server-sent events
Preparing the ground
Transforming streams of data using enumeratees
Implementing a publish/subscribe system using Akka
Bidirectional streaming with WebSockets
Controlling the data flow
Summary
6. Leveraging the Play Stack – Security, Internationalization, Cache, and the HTTP Client
Handling security concerns
Authentication
Cross-site scripting
Cross-site request forgery
HTTP request filters
Using the CSRF filter
Enabling HTTPS
Saving computation time using cache
Serving content in several languages
Calling remote web services
Background – the OAuth 2.0 protocol
Integrating your application with your preferred social network
Implementing the OAuth client
Calling the HTTP API of your preferred social network
Summary
7. Scaling Your Codebase and Deploying Your Application
Making an action's logic reusable and composable with action builders
Capturing the logic of actions that use blocking APIs
Capturing the logic of actions that require authentication
Combining action builders
Modularizing your code
Applying the inversion of control principle
Using dynamic calls in route definitions
Setting up a dependency injection system
Making your code injectable
Mocking components
Splitting your code into several artifacts
Splitting your controller layer into several artifacts
Application deployment
Deploying to your dedicated infrastructure
Deploying to the cloud
Handling per environment configuration
Overriding configuration settings using Java system properties
Using different configuration files
Summary
Index

Play Framework Essentials

Copyright © 2014 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: September 2014
Production reference: 1190914
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78398-240-0
www.packtpub.com
Cover image by Pratyush Mohanta ()

Credits

Author
Julien Richard-Foy
Reviewers
Shannon –jj Behrens
CĂ©dric Chantepie
Commissioning Editor
Amarabha Banerjee
Acquisition Editor
Vinay Argekar
Content Development Editor
Akashdeep Kundu
Technical Editors
Indrajit A. Das
Taabish Khan
Humera Shaikh
Copy Editors
Deepa Nambiar
Laxmi Subramanian
Project Coordinator
Kartik Vedam
Proofreaders
Simran Bhogal
Maria Gould
Ameesha Green
Paul Hindle
Indexers
Monica Ajmera Mehta
Tejal Soni
Graphics
Abhinash Sahu
Production Coordinators
Aparna Bhagat
Manu Joseph
Cover Work
Aparna Bhagat

About the Author

Julien Richard-Foy likes to design code that seamlessly expresses the ideas he has in mind. He likes finding the right level of abstraction, separating concerns, or whatever else that makes the code easy to reason about, to maintain and to grow.
He works at Zengularity, the company that created the Play framework, and actively contributes to the evolution of the framework.
He aims at working on technically challenging and innovative projects that have a positive envir...

Table of contents

  1. Play Framework Essentials