MessagesActionBuilder
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.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
Members list
Value members
Inherited methods
Compose this ActionFunction with another, with this one applied first.
Compose this ActionFunction with another, with this one applied first.
Value parameters
- other
-
ActionFunction with which to compose
Attributes
- Returns
-
The new ActionFunction
- Definition Classes
- Inherited from:
- ActionBuilder
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!")
}
Value parameters
- block
-
the action code
Attributes
- Returns
-
an action
- Inherited from:
- ActionBuilder
Constructs an Action with default content.
Constructs an Action with default content.
For example:
val echo = Action { request =>
Ok("Got request [" + request + "]")
}
Value parameters
- block
-
the action code
Attributes
- Returns
-
an action
- Inherited from:
- ActionBuilder
Constructs an ActionBuilder with the given BodyParser. The result can then be applied directly to a block.
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 + "]")
}
Type parameters
- A
-
the type of the request body
Value parameters
- bodyParser
-
the
BodyParserto use to parse the request body
Attributes
- Returns
-
an action
- Inherited from:
- ActionBuilder
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")
}
}
Value parameters
- block
-
the action code
Attributes
- Returns
-
an action
- Inherited from:
- ActionBuilder
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")
}
}
Value parameters
- block
-
the action code
Attributes
- Returns
-
an action
- Inherited from:
- ActionBuilder
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")
}
}
Value parameters
- block
-
the action code
Attributes
- Returns
-
an action
- Inherited from:
- ActionBuilder
Attributes
- Inherited from:
- ActionFunction
Compose another ActionFunction with this one, with this one applied last.
Compose another ActionFunction with this one, with this one applied last.
Value parameters
- other
-
ActionFunction with which to compose
Attributes
- Returns
-
The new ActionFunction
- Inherited from:
- ActionFunction
Inherited and Abstract methods
Attributes
- Returns
-
The execution context to run the request in.
- Inherited from:
- ActionFunction
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.
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.
Value parameters
- block
-
The block of code to invoke
- request
-
The request
Attributes
- Returns
-
A future of the result
- Inherited from:
- ActionFunction
Attributes
- Returns
-
The BodyParser to be used by this ActionBuilder if no other is specified
- Inherited from:
- ActionBuilder