Book Image

Play Framework Cookbook - Second Edition

By : Alexander Reelsen, Giancarlo Inductivo
Book Image

Play Framework Cookbook - Second Edition

By: Alexander Reelsen, Giancarlo Inductivo

Overview of this book

<p>As web and mobile systems become more sophisticated, anchoring systems in a mature, solid framework has become increasingly important. Play 2 provides developers with the necessary tools to build robust web applications.</p> <p>This book is a compilation of useful recipes aimed at helping developers discover the power of Play 2. The introductory section serves as a primer to Play Framework, wherein all the fundamentals of the framework are covered extensively. It then explains the usage of controllers and how modules can be leveraged for optimal performance. Next, the book walks you through creating and using APIs, followed by extensive real-world applications. Finally, you will learn to manage applications post production.</p>
Table of Contents (15 chapters)
Play Framework Cookbook Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Building a flexible registration module


In this recipe, we will create a new registration module that will manage user registration and authentication requests. Creating a module for this allows us to reuse a very common workflow in the modern web application.

How to do it…

For Java, we need to perform the following steps:

  1. Run the foo_java application with Hot-Reloading enabled:

        activator "~run"
    
  2. Inside the modules directory, foo_java/modules, generate the registration module project using the activator:

        activator new registration play-java
    
  3. Add the dependency between the root project, foo_java, and the module, registration, in foo_java/build.sbt:

        lazy val root = (project in file("."))
          .enablePlugins(PlayJava)
          .aggregate(filemon)
          .dependsOn(filemon)
          .aggregate(registration)
          .dependsOn(registration)
    
        lazy val filemon = (project in file("modules/filemon"))
          .enablePlugins(PlayJava)
    
        lazy val registration = (project in file("modules/registration...