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)
Deprecated.
Use
#Context(Long, play.api.mvc.RequestHeader, Request, Response, Session, Flash, Map, Lang, JavaContextComponents) instead. Since 2.7.0. |
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,
Lang lang,
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.
|
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,
Lang lang,
play.core.j.JavaContextComponents components)
Creates a new HTTP context.
|
Modifier and Type | Method and Description |
---|---|
play.api.mvc.RequestHeader |
_requestHeader()
Deprecated.
Use
request() .asScala() instead. Since 2.7.0. |
boolean |
changeLang(Lang lang)
Deprecated.
Deprecated as of 2.7.0. Use
MessagesApi.setLang(Result, Lang) . |
boolean |
changeLang(java.lang.String code)
Deprecated.
Deprecated as of 2.7.0. Use
MessagesApi.setLang(Result, Lang) . |
void |
clearLang()
Deprecated.
Deprecated as of 2.7.0. Use
MessagesApi.clearLang(Result) . |
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()
Deprecated.
Deprecated as of 2.7.0. Inject a
FileMimeTypes and use the FileMimeTypes.fileMimeTypes method instead. |
Http.Flash |
flash()
Deprecated.
Deprecated as of 2.7.0. Use
Http.RequestHeader.flash() and Result instead. |
java.lang.Long |
id()
Deprecated.
Deprecated as of 2.7.0 Use
Http.RequestHeader.id() instead. |
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()
Deprecated.
Deprecated as of 2.7.0. Use
Http.RequestHeader.session() and Result instead. |
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 header (Not used anymore. You could simply pass null, it doesn't matter)request
- 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, 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, Lang lang, 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.lang
- the transient lang to use.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)
#Context(Long, play.api.mvc.RequestHeader, Request, Response, Session, Flash, Map, Lang, JavaContextComponents)
instead. Since 2.7.0.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 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, Lang lang, play.core.j.JavaContextComponents components)
id
- the unique context IDheader
- the request header (Not used anymore. You could simply pass null, it doesn't matter)request
- 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.lang
- the transient lang to use.components
- the context components.public static Http.Context current()
@Deprecated public java.lang.Long id()
Http.RequestHeader.id()
instead.public Http.Request request()
@Deprecated public Http.Response response()
Result
instead.@Deprecated public Http.Session session()
Http.RequestHeader.session()
and Result
instead.@Deprecated public Http.Flash flash()
Http.RequestHeader.flash()
and Result
instead.@Deprecated public play.api.mvc.RequestHeader _requestHeader()
request()
.asScala() instead. Since 2.7.0.public Lang lang()
public Messages messages()
@Deprecated public boolean changeLang(java.lang.String code)
MessagesApi.setLang(Result, Lang)
.code
- New lang code to use (e.g. "fr", "en-US", etc.)@Deprecated public boolean changeLang(Lang lang)
MessagesApi.setLang(Result, Lang)
.lang
- New Lang object to use@Deprecated public void clearLang()
MessagesApi.clearLang(Result)
.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()
@Deprecated public FileMimeTypes fileMimeTypes()
FileMimeTypes
and use the FileMimeTypes.fileMimeTypes
method instead.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.