|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object play.mvc.Controller
public class Controller
Application controller support: The controller receives input and initiates a response by making calls on model objects. This is the class that your controllers should extend.
Field Summary | |
---|---|
static java.lang.ThreadLocal<Router.ActionDefinition> |
_currentReverse
Don't use this directly if you don't know why |
protected static Scope.Flash |
flash
The current flash scope. |
protected static Scope.Params |
params
The current HTTP params. |
protected static Scope.RenderArgs |
renderArgs
The current renderArgs scope: This is a hash map that is accessible during the rendering phase. |
protected static Http.Request |
request
The current HTTP request: the message sent by the client to the server. |
protected static Http.Response |
response
The current HTTP response: The message sent back from the server after a request. |
protected static Scope.RouteArgs |
routeArgs
The current routeArgs scope: This is a hash map that is accessible during the reverse routing phase. |
protected static Scope.Session |
session
The current HTTP session. |
protected static Validation |
validation
The current Validation object. |
Constructor Summary | |
---|---|
Controller()
|
Method Summary | ||
---|---|---|
protected static
|
await(java.util.concurrent.Future<T> future)
|
|
protected static
|
await(java.util.concurrent.Future<T> future,
F.Action<T> callback)
|
|
protected static void |
await(int millis)
|
|
protected static void |
await(int millis,
F.Action0 callback)
|
|
protected static void |
await(java.lang.String timeout)
|
|
protected static void |
await(java.lang.String timeout,
F.Action0 callback)
|
|
protected static void |
badRequest()
Send a 400 Bad request |
|
protected static void |
checkAuthenticity()
Check that the token submitted from a form is valid. |
|
protected static void |
error()
Send a 500 Error response |
|
protected static void |
error(java.lang.Exception reason)
Send a 500 Error response |
|
protected static void |
error(int status,
java.lang.String reason)
Send a 5xx Error response |
|
protected static void |
error(java.lang.String reason)
Send a 500 Error response |
|
protected static void |
flash(java.lang.String key,
java.lang.Object value)
Add a value to the flash scope |
|
protected static void |
forbidden()
Send a 403 Forbidden response |
|
protected static void |
forbidden(java.lang.String reason)
Send a 403 Forbidden response |
|
protected static
|
getActionAnnotation(java.lang.Class<T> clazz)
Retrieve annotation for the action method |
|
protected static
|
getControllerAnnotation(java.lang.Class<T> clazz)
Retrieve annotation for the controller class |
|
protected static java.lang.Class<? extends Controller> |
getControllerClass()
Retrieve the controller class |
|
protected static
|
getControllerInheritedAnnotation(java.lang.Class<T> clazz)
Retrieve annotation for the controller class |
|
protected static void |
notFound()
Send a 404 Not Found reponse |
|
protected static void |
notFound(java.lang.String what)
Send a 404 Not Found response |
|
protected static void |
notFoundIfNull(java.lang.Object o)
Send a 404 Not Found response if object is null |
|
protected static void |
notFoundIfNull(java.lang.Object o,
java.lang.String what)
Send a 404 Not Found response if object is null |
|
protected static void |
notModified()
Send a 304 Not Modified response |
|
protected static void |
ok()
Send a 200 OK response |
|
protected static void |
parent()
Deprecated. |
|
protected static void |
parent(java.util.Map<java.lang.String,java.lang.Object> map)
Deprecated. |
|
protected static void |
parent(java.lang.Object... args)
Deprecated. |
|
protected static void |
redirect(java.lang.String url)
Send a 302 redirect response. |
|
protected static void |
redirect(java.lang.String url,
boolean permanent)
Send a Redirect response. |
|
protected static void |
redirect(java.lang.String action,
boolean permanent,
java.lang.Object... args)
Redirect to another action |
|
static void |
redirect(java.lang.String action,
java.lang.Object... args)
302 Redirect to another action |
|
protected static void |
redirectToStatic(java.lang.String file)
Send a 302 redirect response. |
|
protected static void |
render(java.lang.Object... args)
Render the corresponding template (@see template() ). |
|
protected static void |
renderBinary(java.io.File file)
Return a 200 OK application/binary response |
|
protected static void |
renderBinary(java.io.File file,
java.lang.String name)
Return a 200 OK application/binary response with content-disposition attachment |
|
protected static void |
renderBinary(java.io.InputStream is)
Return a 200 OK application/binary response |
|
protected static void |
renderBinary(java.io.InputStream is,
long length)
Return a 200 OK application/binary response. |
|
protected static void |
renderBinary(java.io.InputStream is,
java.lang.String name)
Return a 200 OK application/binary response with content-disposition attachment. |
|
protected static void |
renderBinary(java.io.InputStream is,
java.lang.String name,
boolean inline)
Return a 200 OK application/binary response with content-disposition attachment. |
|
protected static void |
renderBinary(java.io.InputStream is,
java.lang.String name,
long length)
Return a 200 OK application/binary response with content-disposition attachment. |
|
protected static void |
renderBinary(java.io.InputStream is,
java.lang.String name,
long length,
boolean inline)
Return a 200 OK application/binary response with content-disposition attachment. |
|
protected static void |
renderBinary(java.io.InputStream is,
java.lang.String name,
long length,
java.lang.String contentType,
boolean inline)
Return a 200 OK application/binary response with content-disposition attachment. |
|
protected static void |
renderBinary(java.io.InputStream is,
java.lang.String name,
java.lang.String contentType,
boolean inline)
Return a 200 OK application/binary response with content-disposition attachment |
|
protected static void |
renderHtml(java.lang.Object html)
Return a 200 OK text/html response |
|
protected static void |
renderJSON(java.lang.Object o)
Render a 200 OK application/json response |
|
protected static void |
renderJSON(java.lang.Object o,
JsonSerializer<?>... adapters)
Render a 200 OK application/json response. |
|
protected static void |
renderJSON(java.lang.Object o,
java.lang.reflect.Type type)
Render a 200 OK application/json response |
|
protected static void |
renderJSON(java.lang.String jsonString)
Render a 200 OK application/json response |
|
protected static void |
renderTemplate(java.util.Map<java.lang.String,java.lang.Object> args)
Render the template corresponding to the action's package-class-method name (@see template() ). |
|
protected static void |
renderTemplate(java.lang.String templateName,
java.util.Map<java.lang.String,java.lang.Object> args)
Render a specific template. |
|
protected static void |
renderTemplate(java.lang.String templateName,
java.lang.Object... args)
Render a specific template |
|
protected static void |
renderText(java.lang.CharSequence pattern,
java.lang.Object... args)
Return a 200 OK text/plain response |
|
protected static void |
renderText(java.lang.Object text)
Return a 200 OK text/plain response |
|
protected static void |
renderXml(org.w3c.dom.Document xml)
Return a 200 OK text/xml response |
|
protected static void |
renderXml(java.lang.Object o)
Return a 200 OK text/xml response. |
|
protected static void |
renderXml(java.lang.Object o,
com.thoughtworks.xstream.XStream xstream)
Return a 200 OK text/xml response |
|
protected static void |
renderXml(java.lang.String xml)
Return a 200 OK text/xml response |
|
protected static Router.ActionDefinition |
reverse()
|
|
protected static void |
suspend(int millis)
Deprecated. |
|
protected static void |
suspend(java.lang.String timeout)
Deprecated. |
|
protected static java.lang.String |
template()
Work out the default template to load for the invoked action. |
|
protected static java.lang.String |
template(java.lang.String templateName)
Work out the default template to load for the action. |
|
protected static boolean |
templateExists(java.lang.String templateName)
|
|
protected static void |
todo()
Send a todo response |
|
protected static void |
unauthorized()
Send a 401 Unauthorized response |
|
protected static void |
unauthorized(java.lang.String realm)
Send a 401 Unauthorized response |
|
protected static void |
waitFor(java.util.concurrent.Future<?> task)
Deprecated. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static Http.Request request
protected static Http.Response response
protected static Scope.Session session
protected static Scope.Flash flash
protected static Scope.Params params
protected static Scope.RenderArgs renderArgs
protected static Scope.RouteArgs routeArgs
protected static Validation validation
public static java.lang.ThreadLocal<Router.ActionDefinition> _currentReverse
Constructor Detail |
---|
public Controller()
Method Detail |
---|
protected static void renderText(java.lang.Object text)
text
- The response contentprotected static void renderHtml(java.lang.Object html)
html
- The response contentprotected static void renderText(java.lang.CharSequence pattern, java.lang.Object... args)
pattern
- The response content to be formatted (with String.format)args
- Args for String.formatprotected static void renderXml(java.lang.String xml)
xml
- The XML stringprotected static void renderXml(org.w3c.dom.Document xml)
xml
- The DOM document objectprotected static void renderXml(java.lang.Object o)
o
- the object to serializeprotected static void renderXml(java.lang.Object o, com.thoughtworks.xstream.XStream xstream)
o
- the object to serializexstream
- the XStream object to use for serialization. See XStream's documentation
for details about customizing the output.protected static void renderBinary(java.io.InputStream is)
is
- The stream to copyprotected static void renderBinary(java.io.InputStream is, long length)
is
- The stream to copylength
- Stream's size in bytes.protected static void renderBinary(java.io.InputStream is, java.lang.String name)
is
- The stream to copyname
- Name of file user is downloading.protected static void renderBinary(java.io.InputStream is, java.lang.String name, long length)
is
- The stream to copy. Content is streamed.name
- Name of file user is downloading.length
- Stream's size in bytes.protected static void renderBinary(java.io.InputStream is, java.lang.String name, boolean inline)
is
- The stream to copyname
- Name of file user is downloading.inline
- true to set the response Content-Disposition to inlineprotected static void renderBinary(java.io.InputStream is, java.lang.String name, long length, boolean inline)
is
- The stream to copyname
- The attachment namelength
- Stream's size in bytes.inline
- true to set the response Content-Disposition to inlineprotected static void renderBinary(java.io.InputStream is, java.lang.String name, java.lang.String contentType, boolean inline)
is
- The stream to copyname
- The attachment namecontentType
- The content type of the attachmentinline
- true to set the response Content-Disposition to inlineprotected static void renderBinary(java.io.InputStream is, java.lang.String name, long length, java.lang.String contentType, boolean inline)
is
- The stream to copyname
- The attachment namelength
- Content's byte size.contentType
- The content type of the attachmentinline
- true to set the response Content-Disposition to inlineprotected static void renderBinary(java.io.File file)
file
- The file to copyprotected static void renderBinary(java.io.File file, java.lang.String name)
file
- The file to copyname
- The attachment nameprotected static void renderJSON(java.lang.String jsonString)
jsonString
- The JSON stringprotected static void renderJSON(java.lang.Object o)
o
- The Java object to serializeprotected static void renderJSON(java.lang.Object o, java.lang.reflect.Type type)
o
- The Java object to serializetype
- The Type informations for complex generic typesprotected static void renderJSON(java.lang.Object o, JsonSerializer<?>... adapters)
o
- The Java object to serializeadapters
- A set of GSON serializers/deserializers/instance creator to useprotected static void notModified()
protected static void badRequest()
protected static void unauthorized(java.lang.String realm)
realm
- The realm nameprotected static void unauthorized()
protected static void notFound(java.lang.String what)
what
- The Not Found resource nameprotected static void ok()
protected static void todo()
protected static void notFoundIfNull(java.lang.Object o)
o
- The object to checkprotected static void notFoundIfNull(java.lang.Object o, java.lang.String what)
o
- The object to checkwhat
- The Not Found resource nameprotected static void notFound()
protected static void checkAuthenticity()
play.templates.FastTags._authenticityToken()
protected static void forbidden(java.lang.String reason)
reason
- The reasonprotected static void forbidden()
protected static void error(int status, java.lang.String reason)
status
- The exact status codereason
- The reasonprotected static void error(java.lang.String reason)
reason
- The reasonprotected static void error(java.lang.Exception reason)
reason
- The reasonprotected static void error()
protected static void flash(java.lang.String key, java.lang.Object value)
key
- The keyvalue
- The valueprotected static void redirect(java.lang.String url)
url
- The Location to redirectprotected static void redirectToStatic(java.lang.String file)
file
- The Location to redirectprotected static void redirect(java.lang.String url, boolean permanent)
url
- The Location to redirectpermanent
- true -> 301, false -> 302public static void redirect(java.lang.String action, java.lang.Object... args)
action
- The fully qualified action name (ex: Application.index)args
- Method argumentsprotected static void redirect(java.lang.String action, boolean permanent, java.lang.Object... args)
action
- The fully qualified action name (ex: Application.index)permanent
- true -> 301, false -> 302args
- Method argumentsprotected static boolean templateExists(java.lang.String templateName)
protected static void renderTemplate(java.lang.String templateName, java.lang.Object... args)
templateName
- The template nameargs
- The template dataprotected static void renderTemplate(java.lang.String templateName, java.util.Map<java.lang.String,java.lang.Object> args)
templateName
- The template name.args
- The template data.protected static void renderTemplate(java.util.Map<java.lang.String,java.lang.Object> args)
template()
).
args
- The template data.protected static void render(java.lang.Object... args)
template()
).
args
- The template dataprotected static java.lang.String template()
protected static java.lang.String template(java.lang.String templateName)
protected static <T extends java.lang.annotation.Annotation> T getActionAnnotation(java.lang.Class<T> clazz)
clazz
- The annotation class
protected static <T extends java.lang.annotation.Annotation> T getControllerAnnotation(java.lang.Class<T> clazz)
clazz
- The annotation class
protected static <T extends java.lang.annotation.Annotation> T getControllerInheritedAnnotation(java.lang.Class<T> clazz)
clazz
- The annotation class
protected static java.lang.Class<? extends Controller> getControllerClass()
@Deprecated protected static void parent(java.lang.Object... args)
@Deprecated protected static void parent()
@Deprecated protected static void parent(java.util.Map<java.lang.String,java.lang.Object> map)
@Deprecated protected static void suspend(java.lang.String timeout)
Important: The method will not resume on the line after you call this. The method will be called again as if there was a new HTTP request.
timeout
- Period of time to wait, e.g. "1h" means 1 hour.@Deprecated protected static void suspend(int millis)
Important: The method will not resume on the line after you call this. The method will be called again as if there was a new HTTP request.
millis
- Number of milliseconds to wait until trying again.@Deprecated protected static void waitFor(java.util.concurrent.Future<?> task)
Important: The method will not resume on the line after you call this. The method will be called again as if there was a new HTTP request.
tasks
- protected static void await(java.lang.String timeout)
protected static void await(java.lang.String timeout, F.Action0 callback)
protected static void await(int millis)
protected static void await(int millis, F.Action0 callback)
protected static <T> T await(java.util.concurrent.Future<T> future)
protected static <T> void await(java.util.concurrent.Future<T> future, F.Action<T> callback)
protected static Router.ActionDefinition reverse()
ActionDefinition action = reverse(); {
Application.anyAction(anyParam, "toto");
}
String url = action.url;
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |