trait MessagesActionBuilder extends ActionBuilder[MessagesRequest, AnyContent]
This trait is an ActionBuilder that provides a MessagesRequest to the block:
class MyController @Inject()( messagesAction: MessagesActionBuilder, cc: ControllerComponents ) extends AbstractController(cc) { def index = messagesAction { implicit request: MessagesRequest[AnyContent] => Ok(views.html.formTemplate(form)) // twirl template with form builders } }
This is useful when you don't want to have to add play.api.i18n.I18nSupport to a controller for form processing.
- Source
- MessagesRequest.scala
- Alphabetic
- By Inheritance
- MessagesActionBuilder
- ActionBuilder
- ActionFunction
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def executionContext: ExecutionContext
- returns
The execution context to run the request in.
- Attributes
- protected
- Definition Classes
- ActionFunction
- abstract def invokeBlock[A](request: Request[A], block: (MessagesRequest[A]) => Future[Result]): Future[Result]
Invoke the block.
Invoke the block. This is the main method that an ActionBuilder has to implement, at this stage it can wrap it in any other actions, modify the request object or potentially use a different class to represent the request.
- request
The request
- block
The block of code to invoke
- returns
A future of the result
- Definition Classes
- ActionFunction
- abstract def parser: BodyParser[AnyContent]
- returns
The BodyParser to be used by this ActionBuilder if no other is specified
- Definition Classes
- ActionBuilder
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def andThen[Q[_]](other: ActionFunction[MessagesRequest, Q]): ActionBuilder[Q, AnyContent]
Compose this ActionFunction with another, with this one applied first.
Compose this ActionFunction with another, with this one applied first.
- other
ActionFunction with which to compose
- returns
The new ActionFunction
- Definition Classes
- ActionBuilder → ActionFunction
- final def apply(block: => Result): Action[AnyContent]
Constructs an
Action
with default content, and no request parameter.Constructs an
Action
with default content, and no request parameter.For example:
val hello = Action { Ok("Hello!") }
- block
the action code
- returns
an action
- Definition Classes
- ActionBuilder
- final def apply(block: (MessagesRequest[AnyContent]) => Result): Action[AnyContent]
Constructs an
Action
with default content.Constructs an
Action
with default content.For example:
val echo = Action { request => Ok("Got request [" + request + "]") }
- block
the action code
- returns
an action
- Definition Classes
- ActionBuilder
- final def apply[A](bodyParser: BodyParser[A]): ActionBuilder[MessagesRequest, A]
Constructs an ActionBuilder with the given BodyParser.
Constructs an ActionBuilder with the given BodyParser. The result can then be applied directly to a block.
For example:
val echo = Action(parse.anyContent) { request => Ok("Got request [" + request + "]") }
- A
the type of the request body
- bodyParser
the
BodyParser
to use to parse the request body- returns
an action
- Definition Classes
- ActionBuilder
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- final def async[A](bodyParser: BodyParser[A])(block: (MessagesRequest[A]) => Future[Result]): Action[A]
Constructs an
Action
with the given BodyParser that returns a future of a result.Constructs an
Action
with the given BodyParser that returns a future of a result.For example:
val hello = Action.async(parse.anyContent) { request => ws.url(request.getQueryString("url").get).get().map { r => if (r.status == 200) Ok("The website is up") else NotFound("The website is down") } }
- block
the action code
- returns
an action
- Definition Classes
- ActionBuilder
- final def async(block: (MessagesRequest[AnyContent]) => Future[Result]): Action[AnyContent]
Constructs an
Action
that returns a future of a result, with default content.Constructs an
Action
that returns a future of a result, with default content.For example:
val hello = Action.async { request => ws.url(request.getQueryString("url").get).get().map { r => if (r.status == 200) Ok("The website is up") else NotFound("The website is down") } }
- block
the action code
- returns
an action
- Definition Classes
- ActionBuilder
- final def async(block: => Future[Result]): Action[AnyContent]
Constructs an
Action
that returns a future of a result, with default content, and no request parameter.Constructs an
Action
that returns a future of a result, with default content, and no request parameter.For example:
val hello = Action.async { ws.url("http://www.playframework.com").get().map { r => if (r.status == 200) Ok("The website is up") else NotFound("The website is down") } }
- block
the action code
- returns
an action
- Definition Classes
- ActionBuilder
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
- def compose[B](other: ActionBuilder[Request, B]): ActionBuilder[MessagesRequest, B]
- Definition Classes
- ActionFunction
- def compose[Q[_]](other: ActionFunction[Q, Request]): ActionFunction[Q, MessagesRequest]
Compose another ActionFunction with this one, with this one applied last.
Compose another ActionFunction with this one, with this one applied last.
- other
ActionFunction with which to compose
- returns
The new ActionFunction
- Definition Classes
- ActionFunction
- def composeAction[A](action: Action[A]): Action[A]
Compose the action with other actions.
Compose the action with other actions. This allows mixing in of various actions together.
- action
The action to compose
- returns
The composed action
- Attributes
- protected
- Definition Classes
- ActionBuilder
- def composeParser[A](bodyParser: BodyParser[A]): BodyParser[A]
Compose the parser.
Compose the parser. This allows the action builder to potentially intercept requests before they are parsed.
- bodyParser
The body parser to compose
- returns
The composed body parser
- Attributes
- protected
- Definition Classes
- ActionBuilder
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)