You are previewing Instant Play Framework Starter.
O'Reilly logo
Instant Play Framework Starter

Book Description

Build your web applications from the ground up with the Play framework for Java and Scala

  • Learn something new in an Instant! A short, fast, focused guide delivering immediate results.

  • Get started with Play 2.1

  • Build your own web application with Java and Scala

  • Handle user input with forms and access data with Ebean, Anorm, and Slick

In Detail

Play is a full-featured Java and Scala web framework for building modern, high-performance web applications. It is characterized by its simplicity and scalability.

With its lightweight, stateless, and web-friendly architecture, Play focuses on developer experience to make web application development fun.

Instant Play Framework Starter is the ideal companion to start developing web applications with Play. The building blocks of a typical web application are carefully designed following an on-going example.

Instant Play Framework Starter starts with a quick setup and running a first sample. Then, the anatomy of a typical Play application is outlined. More features are added step by step to an example application. The result is the prototype of a highly scalable web application.The example is implemented in Java and in Scala. It consists of building blocks you will find in every Play application. In particular, you will learn how views are rendered with the template engine, how HTTP routes are used to define the navigation rules, and how to separate the application logic of controllers from the business logic of the model. This separation is the result of a careful application design, which makes it easy to add features like data binding and validation. Finally you will see how easy it is to adapt different database access libraries.

Instant Play Framework Starter will help you to get started with Play and develop your first application. Packed with examples, it is easy to follow the design of a real-world application. You are able to compare the difference between a Java- and a Scala-based Play application and to decide which language fits your needs best. All topics covered in the book are described with the aim to serve as a reference for future web application development with Play.

Table of Contents

  1. Instant Play Framework Starter
    1. Instant Play Framework Starter
    2. Credits
    3. About the Author
    4. About the Reviewers
    5. www.packtpub.com
      1. Support files, eBooks, discount offers and more
    6. packtlib.packtpub.com
      1. Why Subscribe?
      2. Free Access for Packt account holders
    7. 1. Instant Play Framework Starter
      1. So, what is Play?
      2. Installation
        1. Step 1 – What do I need?
        2. Step 2 – Downloading Play
        3. Step 3 – Setting the PATH environment variable
        4. Step 4 – Testing the Play installation
        5. And that's it!
      3. Quick start – Creating your first Play application
        1. Step 1 – Creating a new Play application
          1. Structure of a Play application
            1. The app/ folder
            2. The conf/ directory
            3. The project/ folder
            4. The public/ folder
            5. The test/ folder
        2. Step 2 – Using the Play console
          1. Starting our application
          2. Play console commands
          3. Closing the console
        3. Step 3 – Modifying our application
          1. Fast turnaround – change your code and hit reload!
          2. Stripped down and optimized stack traces
        4. Step 4 – Setting up your preferred IDE
          1. IntelliJ IDEA
          2. Eclipse
          3. Other IDEs
      4. Top features you need to know about
        1. 1 – Designing a Play application
          1. Introducing our sample application
          2. Defining the domain model
            1. The Java model
            2. The Scala model
          3. Designing the HTTP interface with the routes file
            1. Defining the application routes
            2. Dynamic request paths and variables
            3. Testing the routes
          4. Handling HTTP requests by controller actions
            1. Providing dummy implementations
            2. URL redirection with reverse routes
            3. Implementing controller actions
            4. The Java code
            5. The Scala code
              1. What comes next
          5. Composing the UI from view templates
            1. Syntax of view templates
              1. View parameters
              2. View imports
              3. View expressions
            2. Composing view templates
              1. Example
              2. Nesting view templates
          6. Implementing the phone book views
            1. Prerequisites
            2. The index view template
            3. The list view template
            4. The main view template
              1. Fine-tuning the CSS style
            5. Providing some test data
        2. 2 – Dealing with user input
          1. Defining a form
            1. The server side
              1. Binding data with a Java form
              2. Binding data with a Scala form
            2. The client side
          2. Validating user input
            1. The server side
              1. Defining constraints in Java
              2. Defining constraints in Scala
            2. The client side
          3. Using form template helpers
        3. 3 – Connecting to a database
          1. Accessing data with Ebean for Java
            1. Customizing the configuration
            2. Creating the database schema
            3. Implementing the model
            4. Running the application
          2. Accessing data with Anorm for Scala
            1. Customizing the configuration
            2. Creating the database schema
            3. Implementing the model
            4. Running the application
          3. Accessing data with Slick for Scala
            1. Customizing the configuration
            2. Implementing the model
              1. The data access object
              2. The data access layer
            3. Generating the database schema
      5. People and places you should get to know
        1. Official sites
        2. Articles and tutorials
        3. Community
        4. Blogs
        5. Twitter