play.mvc
Class Http.Context

java.lang.Object
  extended by play.mvc.Http.Context
Enclosing class:
Http

public static class Http.Context
extends java.lang.Object

The global HTTP context.


Nested Class Summary
static class Http.Context.Implicit
          Import in templates to get implicit HTTP context.
 
Field Summary
 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 Summary
Http.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)
          Creates a new HTTP context.
 
Method Summary
 play.api.mvc.RequestHeader _requestHeader()
          The original Play request Header used to create this context.
 boolean changeLang(java.lang.String code)
          Change durably the lang for the current user.
 void clearLang()
          Clear the lang for the current user.
static Http.Context current()
          Retrieves the current HTTP context, for the current thread.
 Http.Flash flash()
          Returns the current flash scope.
 java.lang.Long id()
          The context id (unique)
 Lang lang()
           
 Http.Request request()
          Returns the current request.
 Http.Response response()
          Returns the current response.
 Http.Session session()
          Returns the current session.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

current

public static java.lang.ThreadLocal<Http.Context> current

args

public java.util.Map<java.lang.String,java.lang.Object> args
Free space to store your request specific data

Constructor Detail

Http.Context

public Http.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)
Creates a new HTTP context.

Parameters:
request - the HTTP request
sessionData - the session data extracted from the session cookie
flashData - the flash data extracted from the flash cookie
Method Detail

current

public static Http.Context current()
Retrieves the current HTTP context, for the current thread.


id

public java.lang.Long id()
The context id (unique)


request

public Http.Request request()
Returns the current request.


response

public Http.Response response()
Returns the current response.


session

public Http.Session session()
Returns the current session.


flash

public Http.Flash flash()
Returns the current flash scope.


_requestHeader

public play.api.mvc.RequestHeader _requestHeader()
The original Play request Header used to create this context. For internal usage only.


lang

public Lang lang()
Returns:
the current lang.

changeLang

public boolean changeLang(java.lang.String code)
Change durably the lang for the current user.

Parameters:
code - New lang code to use (e.g. "fr", "en_US", etc.)
Returns:
true if the requested lang was supported by the application, otherwise false.

clearLang

public void clearLang()
Clear the lang for the current user.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object