public static class Http.Context
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Http.Context.Implicit
Import in templates to get implicit HTTP context.
|
Modifier and Type | Field and Description |
---|---|
java.util.Map<java.lang.String,java.lang.Object> |
args
Free space to store your request specific data.
|
static java.lang.ThreadLocal<Http.Context> |
current |
Constructor and Description |
---|
Context(Http.RequestBuilder requestBuilder,
play.core.j.JavaContextComponents components)
Creates a new HTTP context.
|
Context(Http.Request request,
play.core.j.JavaContextComponents components)
Creates a new HTTP context.
|
Context(java.lang.Long id,
play.api.mvc.RequestHeader header,
Http.Request request,
Http.Response response,
Http.Session session,
Http.Flash flash,
java.util.Map<java.lang.String,java.lang.Object> args,
play.core.j.JavaContextComponents components)
Creates a new HTTP context, using the references provided.
|
Context(java.lang.Long id,
play.api.mvc.RequestHeader header,
Http.Request request,
java.util.Map<java.lang.String,java.lang.String> sessionData,
java.util.Map<java.lang.String,java.lang.String> flashData,
java.util.Map<java.lang.String,java.lang.Object> args,
play.core.j.JavaContextComponents components)
Creates a new HTTP context.
|
Modifier and Type | Method and Description |
---|---|
play.api.mvc.RequestHeader |
_requestHeader()
The original Play request Header used to create this context.
|
boolean |
changeLang(Lang lang)
Change durably the lang for the current user.
|
boolean |
changeLang(java.lang.String code)
Change durably the lang for the current user.
|
void |
clearLang()
Clear the lang for the current user.
|
void |
clearTransientLang()
Clear the language for the current request, but don't
change the language cookie.
|
static Http.Context |
current()
Retrieves the current HTTP context, for the current thread.
|
FileMimeTypes |
fileMimeTypes() |
Http.Flash |
flash()
Returns the current flash scope.
|
java.lang.Long |
id()
The context id (unique)
|
Lang |
lang()
The current lang
|
Messages |
messages() |
Http.Request |
request()
Returns the current request.
|
Http.Response |
response()
Deprecated.
Deprecated as of 2.7.0. Use
Result instead. |
Http.Session |
session()
Returns the current session.
|
void |
setTransientLang(Lang lang)
Set the language for the current request, but don't
change the language cookie.
|
void |
setTransientLang(java.lang.String code)
Set the language for the current request, but don't
change the language cookie.
|
java.lang.String |
toString() |
Http.Context |
withRequest(Http.Request request)
Create a new context with the given request.
|
public static java.lang.ThreadLocal<Http.Context> current
public java.util.Map<java.lang.String,java.lang.Object> args
public Context(Http.RequestBuilder requestBuilder, play.core.j.JavaContextComponents components)
requestBuilder
- the HTTP request builder.components
- the context components.public Context(Http.Request request, play.core.j.JavaContextComponents components)
request
- the HTTP requestcomponents
- the context components.public Context(java.lang.Long id, play.api.mvc.RequestHeader header, Http.Request request, java.util.Map<java.lang.String,java.lang.String> sessionData, java.util.Map<java.lang.String,java.lang.String> flashData, java.util.Map<java.lang.String,java.lang.Object> args, play.core.j.JavaContextComponents components)
id
- the unique context IDheader
- the request headerrequest
- the request with bodysessionData
- the session data extracted from the session cookieflashData
- the flash data extracted from the flash cookieargs
- any arbitrary data to associate with this request context.components
- the context components.public Context(java.lang.Long id, play.api.mvc.RequestHeader header, Http.Request request, Http.Response response, Http.Session session, Http.Flash flash, java.util.Map<java.lang.String,java.lang.Object> args, play.core.j.JavaContextComponents components)
id
- the unique context IDheader
- the request headerrequest
- the request with bodyresponse
- the response instance to usesession
- the session instance to useflash
- the flash instance to useargs
- any arbitrary data to associate with this request context.components
- the context components.public static Http.Context current()
public java.lang.Long id()
public Http.Request request()
@Deprecated public Http.Response response()
Result
instead.public Http.Session session()
public Http.Flash flash()
public play.api.mvc.RequestHeader _requestHeader()
public Lang lang()
public Messages messages()
public boolean changeLang(java.lang.String code)
code
- New lang code to use (e.g. "fr", "en-US", etc.)public boolean changeLang(Lang lang)
lang
- New Lang object to usepublic void clearLang()
public void setTransientLang(java.lang.String code)
code
- the language code to set (e.g. "en-US")java.lang.IllegalArgumentException
- If the given language
is not supported by the application.public void setTransientLang(Lang lang)
lang
- the language to setjava.lang.IllegalArgumentException
- If the given language
is not supported by the application.public void clearTransientLang()
public FileMimeTypes fileMimeTypes()
public java.lang.String toString()
toString
in class java.lang.Object
public Http.Context withRequest(Http.Request request)
request
- The request to create the new header from.