This book not only provides you with the opportunity to discover all the basics of Play! Framework 2, but also gives you an insight into its advanced features. This new version of Play! Framework has inherited a lot of features from the previous versions, but it has also learned from them. Thus, it comes with fresh thoughts, a clear vision, and amazing new APIs.
The book will focus on what kind of applications can be built using Play! Framework 2, and what kind of technologies can be used easily with it. In order to demonstrate how it can be easy and fast, we'll build a full application from scratch, integrating as many functionalities as will be needed by any modern web application.
Given that Play! Framework 2 can be used with both Java and Scala, you'll be introduced to the Scala programming language. However, most of the examples are in Java.
Chapter 1, Getting Started with Play! Framework 2, introduces readers to Play! Framework 2 and helps them discover how easy it is to bootstrap your development environment and take a fast track to creating your first application.
Chapter 2, Scala – Taking the First Step, covers just enough of Scala so as to enable you to create advanced Scala templates.
Chapter 3, Templating Easily with Scala, keeps you in touch with the Scala programming language while creating server-side templates. We'll see how to produce views for content and how to combine them. From this chapter, we will start making the application that we will build along with the book.
Chapter 4, Handling Data on the Server Side, explains how to create data on the server side, how to add constraints to them, and then how to generate views on them, while keeping in mind that a web application, especially a CRUD one, mainly deals with data on both server and client sides. By the end of this chapter, you'll be able to create a flow between the browser and the database.
Chapter 5, Dealing with Content, covers how easy it will be to manage different representations of data. We'll introduce how streams are handled by Play! Framework 2, using body parsers. We'll also take the opportunity to use JSON to share our data between the client and the server sides. Also, we'll see how to create an Atom feed of the same data.
Chapter 6, Moving to Real-time Web Applications, demonstrates how to achieve more powerful features (required by any modern web applications) to deal with data in a real-time fashion, using the APIs provided with Play! Framework 2. You'll build an end-to-end workflow using CoffeeScript in the browser to consume events produced on a WebSocket by the server.
Chapter 7, Web Services – At Your Disposal, covers the WS API that Play! Framework 2 includes. This API will leave us consuming or producing content to a different application, using whatever representation of the data we're used to. To illustrate such a use case, we'll connect to Twitter's end points to consume tweets and show them in our application.
Chapter 8, Smashing All Test Layers, gives an overview of all test layers that can be covered using the test features provided by Play! Framework 2. Being a full-stack framework, Play! Framework 2 not only includes binding with testing frameworks, but also mockups for the whole server. By the end of this chapter, you'll be able to test the server-side code and also the user interface using Selenium. The chapter is also the only one that is Scala- and not Java-oriented.
Chapter 9, Code Once, Deploy Everywhere, explains how a Play! Framework application can be used in a continuous integration tool, and how to put it in production by following the continuous-deployment philosophy. You'll also be introduced to the Typesafe console that can help us monitor applications at runtime.
Appendix A, Introducing Play! Framework 2, gives you a deeper insight into the underlying concepts on which Play! Framework is built. We'll see why it is so awesome and what its differences are with the first version. It's also a good place to start, where an overview of the features of Play! Framework 2 can be grasped at once.
Appendix B, Moving Forward, keeps you moving forward with all the very advanced features of Play! Framework 2 that we had to leave aside for a while. You'll also see that the Play! community is expanding very fast and that a lot of helpful plugins are already available.
Appendix C, Materials, gives information about the publicly available sources on GitHub.
As Play! Framework 2 is meant to be "full stack" and completely integrated, the good news is that there are no specific requirements for you or your environment to start creating new web applications.
However, I could give you some common advice, for example, having random hardware is good enough, but having an SSD can be really helpful. This is because we'll be in the JVM world, where compilations will be needed and thus filesystem access can be intense. So just bring your machine and your preferred text editor (or IDE) and go ahead.
The book does not focus on algorithms or model patterns at all. Instead, this book is for web developers. The reader must be interested with the Web world without (especially) being an expert in making web applications. However, a good understanding of third-tier applications over HTTP will be a plus.
The skills required are as few as the prerequisite knowledge required is less. The reader should be familiar with object-oriented languages and have some notion of client-side technologies such as JavaScript, CSS, and HTML.
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: "Now that your machine is prepared, we can create our first project using the play
command."
A block of code is set as follows:
Long chatId = Long.parseLong(queryString.get("chatid")[0]); Map<String,String[]> queryString = request().queryString();
Any command-line input or output is written as follows:
$> cd play-jbook $> play
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "In the new window, click on the Environment Variables... button."
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>
, and mention the book title via the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]>
with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]>
if you are having a problem with any aspect of the book, and we will do our best to address it.