Book Image

Learning Play! Framework 2

By : Andy Petrella
Book Image

Learning Play! Framework 2

By: Andy Petrella

Overview of this book

<p>The Learning Play! Framework 2 has been created for web developers that are building web applications. The core idea is to focus on the HTTP features and to enable them through a simplification lens. Building a web application no longer requires a configuration phase, an environment setup, or a long development lifecycle - it's integrated!<br /><br />Learning Play! Framework 2 will enable any web developers to create amazing web applications taking advantage of the coolest features. It's the fastest way to dive into Play!, focusing on the capabilities by using them in a sample application. Although essentially Java based code, a Scala version is presented as well – giving an opportunity to see some Scala in action.<br /><br />After setting up the machine and learning some Scala, you will construct an application which builds from static to dynamic, before introducing a database. <br /><br />Then we'll focus on how data can be consumed and rendered in several ways. This will enable some real time communication through WebSocket and Server-Sent Event – on both server and client sides.</p> <p>The book will end with testing and deployment, which completes any web development project.</p>
Table of Contents (20 chapters)
Learning Play! Framework 2
Credits
About the Author
Acknowledgement
About the Reviewers
www.packtpub.com
Preface
Materials
Index

More features


Even though you have reached this point after reading the entire book and hacking with all the features introduced, Play! Framework 2 still has some areas where goodies can be learned.

Plugin

The first thing worth mentioning is its internal architecture, which is completely modular. This allows Play 2 to provide developers with a range of end-points to integrate an application perfectly with the framework; for instance, the application life cycle, or its configuration.

These modules are called plugins (as always) and a specific API is available for creating our own. This API not only enables a developer to hook on the application itself, but also helps define global components that can be used along with the whole application. Mostly, they are used for integrating third-party libraries.

Global

Another API is also available for those developers willing to interact with the application with a reduced set of needs; it is completely related to the application itself. This API is called global settings . For more information for the Java part on the 2.0.4 Version, go to http://www.playframework.com/documentation/2.1.0/JavaGlobal.

So far, so good; those APIs are there to extend the application's capabilities in some way. However, there are even more features that a regular Play! 2 application can offer.

Session, cache, and i18n

The two features that are really important for scalable applications are the session-like functionality of a request and the caching system API, available out of the box.

The former enables a request to add or remove session information; this information is stored in the cookie until it expires and, on the other hand, short-lived data can also be consumed using flash scopes. For more information on the Scala part (2.0.4 Version), go to http://www.playframework.org/documentation/2.0.4/ScalaSessionFlash.

For shared data, or for other use cases like that, we could use the cache API that gives the ability to store or fetch data to a centralized destination, which is independent of the user or the request. For more information, check this page (still Version 2.0.4) for Java: http://www.playframework.org/documentation/2.0.4/JavaCache.

We didn't cover natural language and the classic internationalization (i18n) problem, but Play! Framework 2 already has everything covered for us. See http://www.playframework.org/documentation/2.0.4/ScalaI18N.

Frontend languages

In this book we introduced CoffeeScript, but didn't spend enough time on it to grasp every single advantage of it. So, I'd recommend browsing this documentation: http://arcturo.github.com/library/coffeescript/index.html.

We didn't use LESS CSS here, but it's probably one of the best ways to achieve DRYness styling rules for a web application. This language aims to import all missing features to CSS, such as variables or functions. It's very easy to understand, and everything is documented at http://lesscss.org/.