Packages

  • package root
    Definition Classes
    root
  • package play

    Play framework.

    Play framework.

    Play

    http://www.playframework.com

    Definition Classes
    root
  • package api

    Contains the public API for Scala developers.

    Contains the public API for Scala developers.

    Read configuration
    val poolSize = configuration.getInt("engine.pool.size")
    Use the logger
    Logger.info("Hello!")
    Define a Plugin
    class MyPlugin(app: Application) extends Plugin
    Create adhoc applications (for testing)
    val application = Application(new File("."), this.getClass.getClassloader, None, Play.Mode.DEV)
    Definition Classes
    play
  • package cache

    Contains the Cache access API.

    Contains the Cache access API.

    Definition Classes
    api
  • package cluster
    Definition Classes
    api
  • package controllers
    Definition Classes
    api
  • package data

    Contains data manipulation helpers (typically HTTP form handling)

    Contains data manipulation helpers (typically HTTP form handling)

    import play.api.data._
    import play.api.data.Forms._
    
    val taskForm = Form(
      tuple(
        "name" -> text(minLength = 3),
        "dueDate" -> date("yyyy-MM-dd"),
        "done" -> boolean
      )
    )
    Definition Classes
    api
  • package format

    Contains the Format API used by Form.

    Contains the Format API used by Form.

    For example, to define a custom formatter:

    val signedIntFormat = new Formatter[Int] {
    
      def bind(key: String, data: Map[String, String]) = {
        stringFormat.bind(key, data).right.flatMap { value =>
          scala.util.control.Exception.allCatch[Int]
            .either(java.lang.Integer.parseInt(value))
            .left.map(e => Seq(FormError(key, "error.signedNumber", Nil)))
        }
      }
    
      def unbind(key: String, value: Long) = Map(
        key -> ((if (value<0) "-" else "+") + value)
      )
    }
  • package validation

    Contains the validation API used by Form.

    Contains the validation API used by Form.

    For example, to define a custom constraint:

    val negative = Constraint[Int] {
      case i if i < 0 => Valid
      case _ => Invalid("Must be a negative number.")
    }
  • Field
  • FieldMapping
  • Form
  • FormError
  • Forms
  • JodaForms
  • Mapping
  • ObjectMapping
  • ObjectMapping1
  • ObjectMapping10
  • ObjectMapping11
  • ObjectMapping12
  • ObjectMapping13
  • ObjectMapping14
  • ObjectMapping15
  • ObjectMapping16
  • ObjectMapping17
  • ObjectMapping18
  • ObjectMapping19
  • ObjectMapping2
  • ObjectMapping20
  • ObjectMapping21
  • ObjectMapping22
  • ObjectMapping3
  • ObjectMapping4
  • ObjectMapping5
  • ObjectMapping6
  • ObjectMapping7
  • ObjectMapping8
  • ObjectMapping9
  • OptionalMapping
  • RepeatedMapping
  • WrappedMapping
  • package db

    Contains the JDBC database access API.

    Contains the JDBC database access API.

    Example, retrieving a connection from the 'customers' datasource:

    val conn = db.getConnection("customers")
    Definition Classes
    api
  • package http

    Contains standard HTTP constants.

    Contains standard HTTP constants. For example:

    val text = ContentTypes.TEXT
    val ok = Status.OK
    val accept = HeaderNames.ACCEPT
    Definition Classes
    api
  • package i18n

    Contains the internationalisation API.

    Contains the internationalisation API.

    For example, translating a message:

    val msgString = Messages("items.found", items.size)
    Definition Classes
    api
  • package inject

    Play's runtime dependency injection abstraction.

    Play's runtime dependency injection abstraction.

    Play's runtime dependency injection support is built on JSR-330, which provides a specification for declaring how dependencies get wired to components. JSR-330 however does not address how components are provided to or located by a DI container. Play's API seeks to address this in a DI container agnostic way.

    The reason for providing this abstraction is so that Play, the modules it provides, and third party modules can all express their bindings in a way that is not specific to any one DI container.

    Components are bound in the DI container. Each binding is identified by a BindingKey, which is typically an interface that the component implements, and may be optionally qualified by a JSR-330 qualifier annotation. A binding key is bound to a BindingTarget, which describes how the implementation of the interface that the binding key represents is constructed or provided. Bindings may also be scoped using JSR-330 scope annotations.

    Bindings are provided by instances of Module.

    Out of the box, Play provides an implementation of this abstraction using Guice.

    Definition Classes
    api
    See also

    The Module class for information on how to provide bindings.

  • package internal
    Definition Classes
    api
  • package libs

    Contains various APIs that are useful while developing web applications.

    Contains various APIs that are useful while developing web applications.

    Definition Classes
    api
  • package mvc

    Contains the Controller/Action/Result API to handle HTTP requests.

    Contains the Controller/Action/Result API to handle HTTP requests.

    For example, a typical controller:

    class HomeController @Inject() (val controllerComponents: ControllerComponents) extends BaseController {
    
      def index = Action {
        Ok("It works!")
      }
    
    }
    Definition Classes
    api
  • package routing
    Definition Classes
    api
  • package templates
    Definition Classes
    api
  • package test

    Contains test helpers.

    Contains test helpers.

    Definition Classes
    api

package data

Contains data manipulation helpers (typically HTTP form handling)

import play.api.data._
import play.api.data.Forms._

val taskForm = Form(
  tuple(
    "name" -> text(minLength = 3),
    "dueDate" -> date("yyyy-MM-dd"),
    "done" -> boolean
  )
)
Source
package.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. data
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Package Members

  1. package format

    Contains the Format API used by Form.

    Contains the Format API used by Form.

    For example, to define a custom formatter:

    val signedIntFormat = new Formatter[Int] {
    
      def bind(key: String, data: Map[String, String]) = {
        stringFormat.bind(key, data).right.flatMap { value =>
          scala.util.control.Exception.allCatch[Int]
            .either(java.lang.Integer.parseInt(value))
            .left.map(e => Seq(FormError(key, "error.signedNumber", Nil)))
        }
      }
    
      def unbind(key: String, value: Long) = Map(
        key -> ((if (value<0) "-" else "+") + value)
      )
    }
  2. package validation

    Contains the validation API used by Form.

    Contains the validation API used by Form.

    For example, to define a custom constraint:

    val negative = Constraint[Int] {
      case i if i < 0 => Valid
      case _ => Invalid("Must be a negative number.")
    }

Type Members

  1. case class Field(form: Form[_], name: String, constraints: Seq[(String, Seq[Any])], format: Option[(String, Seq[Any])], errors: Seq[FormError], value: Option[String]) extends Product with Serializable

    A form field.

    A form field.

    name

    the field name

    constraints

    the constraints associated with the field

    format

    the format expected for this field

    errors

    the errors associated to this field

    value

    the field value, if any

  2. case class FieldMapping[T](key: String = "", constraints: Seq[Constraint[T]] = Nil)(implicit binder: Formatter[T]) extends Mapping[T] with Product with Serializable

    A mapping for a single field.

    A mapping for a single field.

    key

    the field key

    constraints

    the constraints associated with this field.

  3. case class Form[T](mapping: Mapping[T], data: Map[String, String], errors: Seq[FormError], value: Option[T]) extends Product with Serializable

    Helper to manage HTML form description, submission and validation.

    Helper to manage HTML form description, submission and validation.

    For example, a form handling a User case class submission:

    import play.api.data._
    import play.api.data.Forms._
    import play.api.data.format.Formats._
    
    val userForm = Form(
      mapping(
        "name" -> of[String],
        "age" -> of[Int],
        "email" -> of[String]
      )(User.apply)(User.unapply)
    )
    T

    the type managed by this form

    mapping

    the form mapping, which describes all form fields

    data

    the current form data, used to display the form

    errors

    the collection of errors associated with this form

    value

    a concrete value of type T if the form submission was successful

  4. case class FormError(key: String, messages: Seq[String], args: Seq[Any] = Nil) extends Product with Serializable

    A form error.

    A form error.

    key

    The error key (should be associated with a field using the same key).

    messages

    The form message (often a simple message key needing to be translated), if more than one message is passed the last one will be used.

    args

    Arguments used to format the message.

  5. trait Mapping[T] extends AnyRef

    A mapping is a two-way binder to handle a form field.

  6. trait ObjectMapping extends AnyRef

    Common helper methods for all object mappings - mappings including several fields.

  7. class ObjectMapping1[R, A1] extends Mapping[R] with ObjectMapping
  8. class ObjectMapping10[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10] extends Mapping[R] with ObjectMapping
  9. class ObjectMapping11[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11] extends Mapping[R] with ObjectMapping
  10. class ObjectMapping12[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12] extends Mapping[R] with ObjectMapping
  11. class ObjectMapping13[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13] extends Mapping[R] with ObjectMapping
  12. class ObjectMapping14[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14] extends Mapping[R] with ObjectMapping
  13. class ObjectMapping15[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15] extends Mapping[R] with ObjectMapping
  14. class ObjectMapping16[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16] extends Mapping[R] with ObjectMapping
  15. class ObjectMapping17[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17] extends Mapping[R] with ObjectMapping
  16. class ObjectMapping18[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18] extends Mapping[R] with ObjectMapping
  17. class ObjectMapping19[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19] extends Mapping[R] with ObjectMapping
  18. class ObjectMapping2[R, A1, A2] extends Mapping[R] with ObjectMapping
  19. class ObjectMapping20[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20] extends Mapping[R] with ObjectMapping
  20. class ObjectMapping21[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21] extends Mapping[R] with ObjectMapping
  21. class ObjectMapping22[R, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22] extends Mapping[R] with ObjectMapping
  22. class ObjectMapping3[R, A1, A2, A3] extends Mapping[R] with ObjectMapping
  23. class ObjectMapping4[R, A1, A2, A3, A4] extends Mapping[R] with ObjectMapping
  24. class ObjectMapping5[R, A1, A2, A3, A4, A5] extends Mapping[R] with ObjectMapping
  25. class ObjectMapping6[R, A1, A2, A3, A4, A5, A6] extends Mapping[R] with ObjectMapping
  26. class ObjectMapping7[R, A1, A2, A3, A4, A5, A6, A7] extends Mapping[R] with ObjectMapping
  27. class ObjectMapping8[R, A1, A2, A3, A4, A5, A6, A7, A8] extends Mapping[R] with ObjectMapping
  28. class ObjectMapping9[R, A1, A2, A3, A4, A5, A6, A7, A8, A9] extends Mapping[R] with ObjectMapping
  29. case class OptionalMapping[T](wrapped: Mapping[T], constraints: Seq[Constraint[Option[T]]] = Nil) extends Mapping[Option[T]] with Product with Serializable

    A mapping for optional elements

    A mapping for optional elements

    wrapped

    the wrapped mapping

  30. case class RepeatedMapping[T](wrapped: Mapping[T], key: String = "", constraints: Seq[Constraint[List[T]]] = Nil) extends Mapping[List[T]] with Product with Serializable

    A mapping for repeated elements.

    A mapping for repeated elements.

    wrapped

    The wrapped mapping

  31. case class WrappedMapping[A, B](wrapped: Mapping[A], f1: (A) => B, f2: (B) => A, additionalConstraints: Seq[Constraint[B]] = Nil) extends Mapping[B] with Product with Serializable

    A mapping wrapping another existing mapping with transformation functions.

    A mapping wrapping another existing mapping with transformation functions.

    wrapped

    Existing wrapped mapping

    f1

    Transformation function from A to B

    f2

    Transformation function from B to A

    additionalConstraints

    Additional constraints of type B

Value Members

  1. object Form extends Serializable

    Provides a set of operations for creating Form values.

  2. object FormError extends Serializable
  3. object Forms

    Contains data manipulation helpers (typically HTTP form handling)

    Contains data manipulation helpers (typically HTTP form handling)

    import play.api.data._
    import play.api.data.Forms._
    
    val taskForm = Form(
      of(Task.apply _, Task.unapply _)(
        "name" -> text(minLength = 3),
        "dueDate" -> date("yyyy-MM-dd"),
        "done" -> boolean
      )
    )
  4. object JodaForms
  5. object RepeatedMapping extends Serializable

    Provides a set of operations related to RepeatedMapping values.

Inherited from AnyRef

Inherited from Any

Ungrouped